3 olleh !dlrow m‘I morf .udh I ekil .mca
hello world! I‘m from hdu. I like acm.HintRemember to use getchar() to read ‘\n‘ after the interger T, then you may use gets() to read a line and process it.
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
int T;
(cin>>T).get();
while(T--)
{
int begin,end;
getline(cin,str);
begin=end=0;
for(int i=begin;i<str.size();i++)
{
if(str[i]==' ')
{
end=i;
for(int j=end-1;j>=begin;j--)
cout<<str[j];
cout<<" ";
begin=end+1;
}
}
for(int k=str.size()-1;k>=begin;k--)
cout<<str[k];
cout<<endl;
}
return 0;
}
原文:http://blog.csdn.net/lsgqjh/article/details/44568805