HDU1062 Text Reverse
题意对每个单词进行反转。
使用栈。
#include <bits/stdc++.h>
using namespace std;
char c;
stack<char> st;
int main()
{
int t;
cin >> t;
getchar();
while(t--)
{
while(c=getchar())
{
if(c==' '||c=='\n')
{
while(!st.empty())
{
cout << st.top();
st.pop();
}
if(c=='\n')
{
cout << endl;
break;
}
cout << " ";
}
else
{
st.push(c);
}
}
}
return 0;
}
博客围绕HDU1062 Text Reverse展开,其题意是对每个单词进行反转,解决该问题可使用栈这一数据结构。
1521

被折叠的 条评论
为什么被折叠?



