#include "iostream"
#include "string"
#include "algorithm"
using namespace std;
int main()
{
int TestCase;
while (cin >> TestCase)
{
while (TestCase--)
{
int num;
cin >> num;
cin.get();
for (int i = 0; i < num; i++)
{
string str, ans = "", temp = "";
getline(cin, str);
int length = 0;
length = str.size();
for (int j = 0; j < length; j++)
{
if (str[j] == ' ')//每当遇到一个空格的时候,就将前面的字符进行发向处理
{
reverse(temp.begin(), temp.end());
ans += temp + ' ';
temp = "";
}
else
temp += str[j];
if (j == length - 1)//处理最后的一种情况!
{
reverse(temp.begin(), temp.end());
ans += temp;
}
}
cout << ans << endl;
}
if (TestCase)//格式的输出控制
cout << endl;
}
}
}
zoj 1151 Word Reversal
最新推荐文章于 2019-01-30 21:15:23 发布