Advertisement
discreet0303

Q10252

May 22nd, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class test3 {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         Scanner sc = new Scanner(System.in);
  8.        
  9.         char[] word={'a','b','c','d','e','f',
  10.                      'g','h','i','j','k','l',
  11.                      'm','n','o','p','q','r',
  12.                      's','t','u','v','w','x',
  13.                      'y','z'};
  14.         int[] wordInt = new int[26];
  15.        
  16.                
  17.         String str1 = sc.nextLine().toLowerCase();
  18.         String str2 = sc.nextLine().toLowerCase();
  19.        
  20.         for(int i =0 ; i<str1.length();i++){
  21.            
  22.             for(int j=0 ; j<str2.length();j++){
  23.                
  24.                 if( str1.charAt(i) == str2.charAt(j) ){
  25.                    
  26.                     for(int k =0 ; k<26 ; k++){
  27.                         if(word[k] == str1.charAt(i))
  28.                             wordInt[k]++;
  29.                     }
  30.                    
  31.                 }
  32.             }
  33.         }
  34.        
  35.         for(int i = 0 ; i<26;i++){ 
  36.             if(wordInt[i]>=1)
  37.                     System.out.printf("%c",word[i]);
  38.         }
  39.        
  40.        
  41.        
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement