#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
'프로그래밍 공부 > 백준 (C++)' 카테고리의 다른 글
[C++/백준 1874번] 스택 수열 (0) | 2024.10.11 |
---|---|
[C++/백준 9093번] 괄호 (0) | 2024.10.11 |
[C++/백준 4948번] 베르트랑 공준 (0) | 2024.01.28 |
[C++/백준 4134번] 다음 소수 (0) | 2024.01.27 |
[C++/백준 2485번] 가로수 (0) | 2023.08.25 |