stack大法好
查看原帖
stack大法好
1247040
V_HAPPY666楼主2024/5/26 20:48

STL解法

#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	stack<char>s;
	char a;
	string ans;
	while (cin >> a)
	{
		s.push(a);
		if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')
		{
			s.pop();
		}
	}
	while (!s.empty())
	{
		ans += s.top();
		s.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

2024/5/26 20:48
加载中...