vlatkovski

Poraka

Aug 9th, 2016
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int n;
  8.     cin >> n;
  9.  
  10.     for (int I = 0; I < n; I++) {
  11.         string S, T;
  12.         cin >> S >> T;
  13.  
  14.         int itarget = 0;
  15.         char target = S[itarget];
  16.         char current;
  17.         string S1 = "";
  18.  
  19.         for (unsigned int i = 0; i < T.length(); i++) {
  20.             current = T[i];
  21.             //cout << "i: " << i << ", current: " << current << endl;
  22.             if (current == target) {
  23.                 S1 += current;
  24.                 itarget++;
  25.                 target = S[itarget];
  26.                 //cout << "new S1: " << S1 << ", new itarget: " << itarget << ", new target: " << target << endl;
  27.             }
  28.         }
  29.  
  30.         if (S1 == S) {
  31.             cout << "DA";
  32.         } else {
  33.             cout << "NE";
  34.         }
  35.         //ternary operator (?:) ne raboti??
  36.  
  37.         cout << endl;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment