View Code of Problem 22

import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String a, b;
		char c = 'a';
		while(sc.hasNext()) {
			a = sc.nextLine();
			b = sc.nextLine();
			for(int i = 0; i < 26; i ++) {
				if(a.contains((char)(c + i) + "") && b.contains((char)(c + i) + "")) {
					System.out.print((char)(c + i));
				}
			}
			System.out.println();
		}
	}

}

Double click to view unformatted code.


Back to problem 22