include iostream include stack using namespace std int main stack char

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack<char> read, seq;
char c;
while (c!=EOF)
{
while ((c=getchar())!=' ') { if (c==EOF) return 0; read.push(c);}
while (!read.empty()) { seq.push(read.top()); read.pop(); }
while ((c=getchar())!='\n')
{
if (!seq.empty() && c==seq.top()) seq.pop();
}
if (seq.empty()) cout << "Yes" << endl;
else cout << "No" << endl;
while (!seq.empty()) seq.pop();
}
}