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

Re:为什么WA了呢。请大牛们指点噢。谢谢。小弟感激不尽。

Posted by 227368211 at 2009-11-17 15:36:45 on Problem 2159
In Reply To:为什么WA了呢。请大牛们指点噢。谢谢。小弟感激不尽。 Posted by:D00109 at 2009-10-06 17:03:30
> import java.util.*;
> public class Main {
>     public static void main(String[] args) {
>         inputProcess();
>         process();
>     }
>     private static void inputProcess()
>     {
>         input=new Scanner(System.in);
>         charArray1=input.nextLine().toCharArray();
>         charArray2=input.nextLine().toCharArray();      
>     }
>     private static void process()
>     {
>         if(isEqual(countProcess(charArray1),countProcess(charArray2))==true)
>             System.out.println("YES");
>         else
>             System.out.println("NO");       
>     }
>     private static int[] countProcess(char[] charArray)
>     {
>      Arrays.sort(charArray);
>      int wordCount=1;
>      for(int i=1;i<charArray.length;i++)
>          if(charArray[i]!=charArray[i-1]) wordCount++;
>      int [] result=new int[wordCount];
>      char currentChar=charArray[0];
>      int currentCount=1;
>      int curr=0;
>      for(int i=1;i<charArray.length;i++)
>      {
>        if(charArray[i]==currentChar)
>        {
>            currentCount++;
>            if(i==charArray.length-1)
>                result[curr]=currentCount;
>        }
>        else
>            if(i<charArray.length-1)
>            {
>                result[curr++]=currentCount;
>                currentCount=1;
>                currentChar=charArray[i];
>            }
>            else result[curr]=1;
>      }
>      Arrays.sort(result);
>      return result;
>     }    
>     private static boolean isEqual(int [] list1 , int []list2)
>     {
>      int length=list1.length;
>      for(int i=0;i<length;i++)
>          if(list1[i]!=list2[i]) return false;
>      return true;    
>     }
>     private static Scanner input;
>     private static char[] charArray1;
>     private static char[] charArray2;
> }

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