Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. package project_of_me;
  2.  
  3. import java.util.Scanner;
  4. public class bai_easy
  5. {
  6.    
  7.     public static void main(String[] args)
  8.     {
  9.         //System.setIn(new FileInputStream("D:\\data\\bai2.txt"));
  10.         Scanner sc = new Scanner(System.in);
  11.         int test_case = sc.nextInt();
  12.         for(int tc = 0; tc < test_case; tc++)
  13.     {
  14.     String str1 = new String();
  15.     str1 = sc.next();
  16.     char [] arr1 = new char[str1.length()];
  17.     String str2 = new String();
  18.     str2 =  sc.next();
  19.     char [] arr2 = new char[str2.length()];
  20.            
  21.     if(str1.length() != str2.length())
  22.     {
  23.         System.out.println("(s1,s2) = "+ false);
  24.     }
  25.     else
  26.     {
  27.         for(int i = 0; i < str1.length(); i++)
  28.         {
  29.             arr1[i] = str1.charAt(i);
  30.             arr2[i] = str2.charAt(i);
  31.         }
  32.         int count = 0;
  33.         for(int i = 0; i < arr1.length; i++)
  34.         {
  35.                     for(int j = 0; j < arr1.length; j++)
  36.                     {
  37.             if(arr1[i] == arr2[j])
  38.             {
  39.                             count++;
  40.                             arr1[i] = arr2[j] = ' ';
  41.                             break;
  42.             }
  43.                         else
  44.                         {
  45.                             if(arr1[i] == '?')
  46.                             {
  47.                                 count++;
  48.                                 arr1[i] = ' ';
  49.                             }
  50.                             if(arr2[j] == '?')
  51.                             {
  52.                                 count++;
  53.                                 arr2[j] = ' ';
  54.                             }
  55.                         }
  56.                        
  57.                     }
  58.         }
  59.         if(count < arr1.length)
  60.             System.out.println("#"+(tc+1)+" (s1,s2) " + false);
  61.         else
  62.             System.out.println("#"+(tc+1)+"(s1,s2) " + true);
  63.             }
  64.         }
  65.        
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement