HDU - 1062 Text Reverse(Stack模拟)
#include<iostream>
#include<stack>
using namespace std;
int main()
{
int n;char ch;scanf("%d",&n);getchar();while(n--){
stack<char>s;for(;;){
scanf("%c",&ch);if(ch==' '||ch=='\n'){
while(!s.empty()){
printf("%c",s.top());s.pop();}if(ch=='\n') break;printf(" ");}else s.push(ch);}puts("");}return 0;
}