코딩테스트/백준

[브2] 12605 - 단어순서 뒤집기

ShovelingLife 2024. 12. 2. 11:19

이미 cin을 한번 했기 때문에 ignore

int main()
{
	int n, t = 1;
	cin >> n;
	cin.ignore();

	while (n--)
	{
		string str, tmp;
		getline(cin, str);
		stringstream ss(str);
		stack<string> s;
		while (ss >> tmp)
			s.push(tmp);

		cout << "Case #" << t++ << ": ";

		while (!s.empty())
		{
			cout << s.top() << ' ';
			s.pop();
		}
		cout << '\n';
	}
}