我希望你是我独家记忆

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

URAL_1612

Posted on 2008-12-14 01:00 Hero 阅读(132) 评论(0)  编辑 收藏 引用 所属分类: 代码如诗--ACM
 1 // 1612 C++ Accepted 0.031 129 KB URAL
 2 
 3 //简单字符串处理--字符串分割
 4 //注意tram.tram这种情况
 5 
 6 #include <stdio.h>
 7 #include <stdlib.h>
 8 #include <string.h>
 9 
10 int a, b ;
11 char str[10010] ;
12 char tstr[10010] ;
13 
14 int main()
15 {
16     int len ; a = 0 ; b = 0 ;
17     while( scanf( "%s", str ) != EOF )
18     {
19         len = strlen( str ) ;
20         forint i=0; i<len; i++ )
21         {
22             tstr[0= '\0' ; int tlen = 0 ;
23             if( str[i]>='a' && str[i]<='z' )
24             {
25                 while( str[i]>='a' && str[i]<='z' )
26                 {
27                     tstr[tlen++= str[i++] ;
28                 }
29                 tstr[tlen++= '\0' ;
30                 if( strcmp( tstr, "tram" ) == 0 ) a++ ;
31                 if( strcmp( tstr, "trolleybus" ) == 0 ) b++ ;
32             }
33             else continue ;
34         }
35     }
36 
37     if( a > b ) printf( "Tram driver\n" ) ; 
38     else if( a < b ) printf( "Trolleybus driver\n" ) ;
39     else printf( "Bus driver\n" ) ;
40 
41     return 0 ;
42 }

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