josiftepe

Untitled

Nov 22nd, 2020
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 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.         string a, b;
  11.         cin >> a >> b;
  12.         int i = 0;
  13.         int j = 0;
  14.         int n = a.size();
  15.         int m = b.size();
  16.         while(i < n and j < m) {
  17.             if(i == n or j == m) {
  18.                 break;
  19.             }
  20.             if(a[i] == b[j]) {
  21.                 i += 1;
  22.                 j += 1;
  23.             }
  24.             else {
  25.                 j += 1;
  26.             }
  27.         }
  28.         if(i == n) {
  29.             cout << "DA" << endl;
  30.         }
  31.         else {
  32.             cout << "NE" << endl;
  33.         }
  34.     }
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment