프로그래밍 공부/백준 (C++)
[C++/백준 9093번] 단어 뒤집기
Rocketbabydolls
2024. 10. 11. 17:09
#include <iostream>
#include <stack>
#include <sstream>
using namespace std;
stack<char> s;
int main() {
int N;
cin >> N;
cin.ignore();
for (int i = 0; i < N; i++)
{
string input, token;
getline(cin, input);
stringstream str(input);
while (str >> token)
{
for (int j = 0; j < token.size(); j++)
{
s.push(token[j]);
}
while (!s.empty())
{
cout << s.top();
s.pop();
}
cout << ' ';
}
}
return 0;
}
https://www.acmicpc.net/problem/9093