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

Please Help!!

Posted by chiperortiz at 2007-08-11 06:09:42 on Problem 2629
Some Tips About Common Permutation??

Please In English I Am From Venezuela Sorry!!!
import java.io.*;
import java.util.*;

public class Main {
    
    public static boolean Existe (String Cad, char Opc)
    {
       int Max = Cad.length();
       for (int i=0;i<Max;i++)
           if (Cad.charAt(i) == Opc)
           {
              Cad = Cad.replace(Opc,'!');
              return true;
           }    
       return false;
    } 
    
    public static String Match (String Uno, String Dos)
    {
       int Max = Uno.length();
       String Back = "";
       for (int i=0;i<Max;i++)
       {
          char Opc = Uno.charAt(i);
          if (Existe (Dos,Opc))
              Back += Opc;
       }
      return Back; 
    }
    
    public static void main(String[] args)
    {
       try
       {
          BufferedReader Leer = new BufferedReader (new InputStreamReader (System.in)); 
          String Uno = "";
          while ((Uno = Leer.readLine()) != null)
          {
              StringTokenizer x = new StringTokenizer (Uno);
              if (!x.hasMoreTokens()) continue;
              String Dos = Leer.readLine();
              x = new StringTokenizer (Dos);          
              if (!x.hasMoreTokens())
                while (true)
                {    
                   Dos = Leer.readLine();
                   x = new StringTokenizer (Dos);
                   if (x.hasMoreTokens()) break;
                }  
               String Res = Match (Uno,Dos);
               char Dig[] = Res.toCharArray();
              Arrays.sort(Dig);              
              System.out.println (new String (Dig));              
          }    
       }
       catch (Exception e)
       {}
    }    
}

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