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 |
测试都没有问题但是提交一直是Wrong Answer 求助import java.util.Scanner; public class Main { public static int Sort(String input,int length) { int output = 0; String str[] = input.split(""); for(int i = 0;i<length-1;i++) { for(int j = i+1;j<length;j++) { if(str[i].compareTo(str[j])>0){ output++; } } } return output; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int length = sc.nextInt(); int number = sc.nextInt(); int temp[] = new int[number]; String str[] = new String[number]; sc.nextLine();//吃掉换行符 int big=0;//存储Sort最大值+1 for(int i=0;i<number;i++) { str[i] = sc.nextLine(); temp[i]=Sort(str[i],length); // System.out.println(temp[i]); if(big<=temp[i]) big = temp[i]+1; } System.out.println(big); int flag = 0; for(int i = 0;i<number;i++) { for(int j = 0;j<number;j++) { //选出最小的 输出,然后又big代替输出的temp[i] if(temp[i]>=temp[j]&&temp[flag]>temp[j]) { flag = j; // System.out.println(temp[i]+"?"+temp[j]); } } temp[flag] = big; System.out.println(str[flag]); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator