题目链接:http://ifrog.cc/acm/problem/1127
就是将单词翻转一下, 没什么可写的, 代码如下:
#include<bits/stdc++.h>
using namespace std;
string str;
bool judge(char ch)
{
if(ch >= 'a' && ch <= 'z')
return true;
if(ch >= 'A' && ch <= 'Z')
return true;
return false;
}
int main()
{
char ch;
//freopen("out.txt", "w", stdout);
while(scanf("%c", &ch) != EOF)
{
if(judge(ch))
str += ch;
else
{
reverse(str.begin(), str.end());
cout << str;
str.clear();
printf("%c", ch);
}
}
return 0;
}