/** * This class can take a variable number of parameters on the command * line. Program execution begins with the main() method. The class * constructor is not invoked unless an object of type 'Class1' * created in the main() method. */ import java.io.*; import java.util.StringTokenizer; public class probc { /** * The main entry point for the application. * * @param args Array of parameters passed to the application * via the command line. */ public static void main (String[] args)throws IOException { BufferedReader in=new BufferedReader(new FileReader("probc.in")); PrintWriter out=new PrintWriter(new FileWriter("probc.out")); int N=Integer.parseInt(in.readLine()); for(int set=1;set<=N;set++){ String line1,line2; line1=in.readLine(); line2=in.readLine(); line1=format(line1); line2=format(line2); out.print("Data Set "+set+": "); if(line1.equals(line2))out.println("equal"); else out.println("not equal"); out.println(); } out.flush(); out.close(); } static String format(String s){ //replace duplicate chars s=s.replace('{','('); s=s.replace('[','('); s=s.replace(']',')'); s=s.replace('}',')'); s=s.replace(';',','); //s.replace('[','('); //s.replace('[','('); s=s.toLowerCase(); //fix whitespace StringTokenizer token=new StringTokenizer(s); String ans="."; boolean lastpunc=true; while(token.hasMoreTokens()){ s=token.nextToken(); char first,last; first=s.charAt(0); last=s.charAt(s.length()-1); switch(first){ case '(': case ',': case ':': case ')': case '.': ans=ans+s; break; default: if (!lastpunc) ans=ans+" "; ans=ans+s; break; } switch(last){ case '(': case ',': case ':': case ')': case '.': lastpunc=true; break; default: lastpunc=false; break; } } System.out.println(ans); return ans; } }