| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
各位大牛,帮忙看看,测试数据正确,但是一直是WA,崩溃。谢谢!import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
while(2>1)
{int totalLength;
int numberN=scanner.nextInt();
int numberM=scanner.nextInt();
if(numberN==0&&numberM==0)System.exit(0);
if(numberN==0||numberM==0)totalLength=numberN>numberM?numberN:numberM;
else totalLength=numberN*numberM;
int[]input=new int[totalLength];
int[]temp=new int[totalLength];
int[]counter=new int[totalLength];
int count=0;
for(int i=0;i<totalLength;i++)input[i]=scanner.nextInt();
java.util.Arrays.sort(input);
for(int j=0;j<totalLength;j++)
{ temp[count]=input[j];
for(int k=j+1;k<totalLength;k++)
{if(temp[count]==input[k]){counter[count]++;j++;}}
count++;
}
int first=0,second=0;
for(int h=0;h<count;h++)
if(counter[h]>first)
{second=first;
first=counter[h];}
if(first!=0){
for(int g=0;g<count;g++)
if(counter[g]==second)System.out.print(temp[g]+" ");System.out.println();}
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator