Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

请各位大虾帮忙看看,怎么会是WA呢?

Posted by A0317405 at 2004-01-04 22:47:31 on Problem 1007
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator