我希望你是我独家记忆

一段永远封存的记忆,随风而去
posts - 263, comments - 31, trackbacks - 0, articles - 3
   :: 首页 :: 新随笔 ::  :: 聚合  :: 管理

HLOJ_1028

Posted on 2009-08-03 15:44 Hero 阅读(251) 评论(0)  编辑 收藏 引用 所属分类: 代码如诗--ACM
 1 //HLOJ 1028  Accepted  15 196 730 C++  
 2 
 3 #include <iostream>
 4 #include <string>
 5 
 6 using namespace std ;
 7 
 8 int tnum ;
 9 string instr ;
10 
11 
12 void print( string str )
13 {
14     int len = str.length() ;
15     forint i=len-1; i>=0; i-- )
16     {
17         cout << str[i] ;
18     }
19 }
20 
21 int main()
22 {
23     while( cin >> tnum )
24     {
25         getchar() ;
26         while( tnum -- )
27         {
28             getline( cin, instr ) ;
29             
30             int len = instr.length() ;
31             string buffer ;
32             forint i=0; i<=len; i++ )
33             {
34                 if( instr[i] == ' ' )
35                 {
36                     print( buffer ) ;
37                     cout << ' ' ;
38                     buffer.clear() ;
39                 }
40                 else if( instr[i] == '\0' )
41                 {
42                     print( buffer ) ;
43                     cout << endl ;
44                     buffer.clear() ;
45                 }
46                 else
47                 {
48                     buffer += instr[i] ; 
49                 }
50             }
51         }
52     }
53 
54     return 0 ;
55 }

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理