| ||||||||||
| 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 | |||||||||
Please Help!!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator