All in All UVA - 10340

#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main() {
	string s, t;
	stack<char> st1, st2;
	while (cin >> s >> t) {
		for (int i = 0; i < s.length(); i++)
			st1.push(s[i]);
		for (int i = 0; i < t.length(); i++)
			st2.push(t[i]);
		while (!st1.empty() && !st2.empty()) {
			if (st1.top() == st2.top()) {
				st1.pop();
				st2.pop();
			}
			else
				st2.pop();
		}
		if (!st1.empty())
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
		while (!st1.empty())
			st1.pop();
		while (!st2.empty())
			st2.pop();
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/malazhuzai/article/details/83591553
ALL