// CCC2006s2CipherTexts // // given a plain and cipher text lines // decode a second ciphertext line. // (simple substitution encryption used) // // Basic string handling import java.io.*; // supports RandomAccessFile & PrintWriter import java.util.Scanner; public class CCC2006s2CipherTexts { public static void main (String[] args) throws IOException { // ======== Open channels to input and output files. ============ Scanner in = new Scanner (new File("s2.5.in")); PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter("s2.5.out"))); int x; String plain = in.next(); String c1 = in.next(); String c2 = in.next(); for (int i = 0 ; i < c2.length() ; i++) { x = c1.indexOf(c2.charAt(i)); if (x == -1) out.print ("."); else out.print (plain.charAt(x)); } // end for out.close(); // really important to flush data to disk's file! } // end main() }