hdoj1062
来源:互联网 发布:linux touch -t 编辑:程序博客网 时间:2024/06/16 21:08
//hdoj 1062 Text Reverse 文本反转
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>char s[1000];using namespace std;int main(){ int n; int i,j,k; cin >> n; getchar(); for( i = 1;i <= n;i++){ j = 0; k = 1; s[j]=getchar(); while(s[j]!='\n'){ if(s[j]!=' '){ j++; s[j]=getchar(); } else { if(k!=1)cout <<" "; k++; for( int l = j-1;l >= 0 ;l--){ cout << s[l]; } j = 0; s[j]=getchar(); } } cout <<" "; for( int l = j-1;l >= 0 ;l--){ cout << s[l]; } cout << endl; } system("pause"); }