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.io.*; import java.util.*; public class Main { public static void main (String args[]) throws Exception { BufferedReader stdin = new BufferedReader( new InputStreamReader(System.in)); String[] dna = new String[100]; int[] a = new int[50]; int i,j,k,temp; String line = stdin.readLine(); String str; StringTokenizer st = new StringTokenizer(line); int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); for(i=0;i<m;i++) { line = stdin.readLine(); dna[i] = line; } for( i=0;i<m;i++) { for( j=0;j<n-1;j++) { for( k=j+1;k<n;k++) {if(dna[i].charAt(j)>dna[i].charAt(k)) { a[i]++; } } } } for(i=0;i<m-1;i++) { for(j=i+1;j<m;j++) { if(a[i]>a[j]) { str=dna[i]; dna[i]=dna[j]; dna[j]=str; temp=a[i]; a[i]=a[j]; a[j]=temp; } } } for(i=0;i<m;i++) {System.out.println(dna[i]); System.out.println(a[i]); } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator