Seal_of_approval

PrStack

Jun 30th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stack>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main (void)
  9. {
  10.     ifstream in ("input.txt");
  11.     ofstream out ("output.txt");
  12.  
  13.     stack <char> s1;
  14.  
  15.     string s_s1 = "";
  16.     string s_s2 = "";
  17.  
  18.     getline(in, s_s1);
  19.     getline(in, s_s2);
  20.  
  21.     for (int i = 0; i < s_s1.length(); i++)
  22.         s1.push(s_s1[i]);
  23.  
  24.     char c;
  25.     bool isOk = true;
  26.  
  27.     if (s1.size() != s_s2.length())
  28.         isOk = false;
  29.     else
  30.     {
  31.         for (int i = 0; i < s_s2.length(); i++)
  32.         {
  33.             c = s1.top();
  34.             s1.pop();
  35.             if (c != s_s2[i])
  36.             {
  37.                 isOk = false;
  38.                 break;
  39.             }
  40.         }
  41.     }
  42.     if (isOk) out << "Yes" << endl;
  43.     else out << "No" << endl;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment