josiftepe

Untitled

Nov 22nd, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int test_case;
  8.     cin >> test_case;
  9.     for(int T = 0; T < test_case; T += 1) {
  10.        
  11.     string Ti;
  12.     string Si;
  13.     int x=0;
  14.     int k=0;
  15.  
  16.     cin>>Ti;
  17.     cin>>Si;
  18.     int p;
  19.     p=Ti.size();
  20.     int u;
  21.     u=Si.size();
  22.     if(p>u){
  23.         cout<<"NE" << endl;
  24.     }
  25.     if((Ti==Si)and(p==u)){
  26.     cout<<"DA" << endl;
  27.     }
  28.     if((Ti!=Si) and (p==u)){
  29.         cout<<"NE" << endl;
  30.     }
  31.     if(p<u){
  32.         for(int i=0; i<p; i+=1){
  33.             while(x<u){
  34.                 if(Ti[i]==Si[x]){
  35.                 k+=1;
  36.                 x+=1;
  37.                 break;
  38.                 }
  39.                 x+=1;
  40.                 }
  41.             }
  42.     if(k==p){
  43.         cout<<"DA" << endl;
  44.     }
  45.     else {
  46.         cout << "NE" << endl;
  47.     }
  48.     }
  49.  
  50.     }
  51.     return 0;
  52. }
  53. /*
  54.  if size of Si > size of Ti -> NO
  55.  if size of Si == size of Ti -> check if they're equal
  56.  
  57.  Si         Ti
  58.  poraka     phorXazkhYhWa
  59.   i          j
  60.  */
  61.  
Advertisement
Add Comment
Please, Sign In to add comment