Advertisement
Guest User

khai.mp13122019

a guest
Dec 13th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. package repairroad;
  2. import java.util.Scanner;
  3. import java.util.Arrays;
  4. public class RepairRoad
  5. {
  6.     public static void main(String[] args)
  7.     {
  8.         Scanner mk= new Scanner(System.in);
  9.         String n= mk.next();
  10.         String m=mk.next();
  11.         int k= n.length();
  12.         int t= m.length();
  13.         if(k !=t)
  14.         {
  15.             System.out.print("(s1,s2)= false"); return;
  16.         }
  17.         String []A= new String[k];
  18.         String []B= new String[t];
  19.         for(int i=0; i< k;i++)
  20.         {
  21.             A[i]= n.substring(i, i+1);
  22.         }
  23.         for(int i=0;i < t;i++)
  24.         {
  25.             B[i]= m.substring(i, i+1);
  26.         }
  27.         int count =0;
  28.         String r= "?";
  29.         int i=0;
  30.         while(i<k)
  31.         {
  32.             if(A[i].equals(r) ) count++;
  33.             else
  34.             {
  35.                 for(int j=0;j<t;j++)
  36.             {
  37.                 if(A[i].equals(B[j]))
  38.                 {
  39.                     count ++;
  40.                     B[i]="";
  41.                     A[i]="";
  42.                    
  43.                 }
  44.                
  45.             }
  46.             }
  47.             i++;
  48.         }
  49.         if(count >=t)
  50.         {
  51.             System.out.print("(s1,s2)= true");
  52.         }
  53.         else
  54.         {
  55.             System.out.print("(s1,s2)= false");
  56.         }
  57.     }
  58.    
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement