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 |
各位大哥请看一下为什么总是WAimport java.util.*; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int lenStr, colum, count, intTemp; String temp; lenStr = sc.nextInt();// 串长度 colum = sc.nextInt();// 行数 String[] strIn = new String[colum]; int[] intIn = new int[colum]; if (lenStr > 0 && lenStr <= 50 && colum > 0 && colum <= 100) { for (int i = 0; i < colum; i++) { strIn[i] = sc.next(); count = 0; temp = strIn[i]; for (int j = 0; j < lenStr - 1; j++) {// 计算sort数值 for (int k = j + 1; k < lenStr - 1; k++) { if (temp.charAt(j) > temp.charAt(k)) { count++; // System.out.println(temp.charAt(j) + " " + // temp.charAt(k)); } } } intIn[i] = count; } // 2轮冒泡排序 for (int i = 0; i < colum; i++) { for (int j = 0; j < colum - i - 1; j++) {// 此时要多减去1 if (intIn[j] > intIn[j + 1]) { intTemp = intIn[j]; intIn[j] = intIn[j + 1]; intIn[j + 1] = intTemp; temp = strIn[j]; strIn[j] = strIn[j + 1]; strIn[j + 1] = temp; } } } for (int i = 0; i < colum; i++) { System.out.println(strIn[i]); } } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator