HDU1062 Text Reverse
HDU1062
题目

AC代码
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stack>
using namespace std;
int main()
{
int n;
char ch;
scanf("%d",&n);
getchar();
while(n--)
{
stack<char> s;
while(1)
{
ch=getchar();
if(ch==' ' || ch=='\n' || ch==EOF)
{
while(!s.empty())
{
printf("%c",s.top());
s.pop();
}
if(ch=='\n' || ch==EOF) break;
printf(" ");
}
else
s.push(ch);
}
cout<<endl;
}
return 0;
}
本文来自博客园,作者:斯文~,转载请注明原文链接:https://www.cnblogs.com/zhiweb/p/15483348.html

浙公网安备 33010602011771号