hdu 1062 Text Reverse

http://acm.hdu.edu.cn/showproblem.php?pid=1062     字符串反转,简单

View Code
 1 #include<iostream>
2 #include<cstring>
3 #include<cstdlib>
4 #include<cstdio>
5 using namespace std;
6 char line[1008];
7 void reverse()
8 {
9 string temp;
10 int i,len=strlen(line);
11 for(i=0;i<len;i++)
12 {
13 if(line[i]==' ') cout<<temp<<" ",temp="";
14 else temp=line[i]+temp;
15 }
16 cout<<temp<<endl;
17 }
18 int main()
19 {
20 int t;
21 cin>>t;
22 getchar();
23 while(t--)
24 {
25 gets(line);
26 //cout<<"line:"<<line<<endl;
27 reverse();
28 }
29 return 0;
30 }


 

posted @ 2012-04-02 19:28  keepmoving89  阅读(126)  评论(0编辑  收藏  举报