您的位置:首页 > 编程语言 > Java开发

ACM 杭电 1004 java

2014-03-21 00:16 309 查看
杭电1004 java 代码!

import java.util.Scanner;;

public class Main {

public static void main(String[] args) {

Scanner scanner=new Scanner(System.in);

int number=scanner.nextInt();

while(number!=0){

String[] tempArray=new String[number];

scanner.nextLine();

for(int i=0;i<number;i++){

tempArray[i]=scanner.nextLine();

}

int max=0;

int id=0;

int[] isGo=new int[number];

for(int i=0;i<number;i++){

int count=0;

if(isGo[i]==1){

continue;

}

for(int j=i;j<number;j++){

if(tempArray[i].equals(tempArray[j])){

count++;

isGo[j]=1;

}

}

if(count>max){

max=count;

id=i;

}

}

System.out.println(tempArray[id]);

number=scanner.nextInt();

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: