zoukankan      html  css  js  c++  java
  • Let the Balloon Rise

     1 import java.util.HashMap;
     2 import java.util.Map;
     3 import java.util.Scanner;
     4 
     5 import javax.swing.text.html.HTMLDocument.Iterator;
     6 
     7 public class Main{
     8     public static void main(String args[]) {
     9         Scanner sc=new Scanner(System.in);
    10         while(sc.hasNext()) {
    11             int n=sc.nextInt();
    12             if(n==0) {
    13                 break;
    14             }
    15             Map<String,Integer> map=new HashMap<String,Integer>();
    16             for(int i=0;i<n;i++) {
    17                 String key=sc.next();
    18                 if(!map.containsKey(key)) {
    19                     map.put(key, 1);
    20                 }
    21                 else {
    22                     int temp=map.get(key);
    23                     map.put(key, ++temp);
    24                 }
    25             }
    26             int max=Integer.MIN_VALUE;
    27             String color="";
    28             java.util.Iterator<String> it=map.keySet().iterator();
    29             while(it.hasNext()) {
    30                 String theKey=it.next();
    31                 int theValue=map.get(theKey);
    32                 if(max<theValue) {
    33                     color=theKey;
    34                     max=theValue;
    35                 }
    36             }
    37             System.out.println(color);
    38         }
    39     }
    40 }

  • 相关阅读:
    zip
    sublime 3 注册码
    css3 文本控制自动换行
    ST3 package control
    cf1139D-Steps to One
    2019-2020 ACM-ICPC, Asia Xuzhou Regional Contest
    2018-2019 ACM-ICPC, Asia Jiaozuo Regional Contest
    Tree
    B
    多源对多源最短路
  • 原文地址:https://www.cnblogs.com/DixinFan/p/9083501.html
Copyright © 2011-2022 走看看