我希望你是我独家记忆

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

HLOJ_1183

Posted on 2009-03-23 17:01 Hero 阅读(106) 评论(0)  编辑 收藏 引用 所属分类: 代码如诗--ACM
 1 //1183      Accepted     0    136    882     C++     特兰克斯
 2 #include <stdio.h>
 3 #include <stdlib.h>
 4 #include <string.h>
 5 
 6 int main()
 7 {
 8     char *pstra = new char[500] ;
 9     char *pstrb = new char[500] ;
10     char *pstrc = new char[500] ;
11 
12     while( scanf( "%s", pstra ) != EOF )
13     {
14         int lena = strlen( pstra ) ;
15         scanf( "%s", pstrb ) ; int lenb = strlen( pstrb ) ;
16         scanf( "%s", pstrc ) ; int lenc = strlen( pstrc ) ;
17 
18         int cnt = 1 ;
19         char *posi = pstra ;
20         while( (posi=strstr(pstra, pstrb)) != NULL )
21         {
22             forint i=1; i<=lenb; i++ )
23             {
24                 *posi = cnt ; posi++ ;
25             }
26             if1 == cnt ) cnt = 2 ;
27             else cnt = 1 ;
28         }
29 
30         cnt = 1 ;
31         forint i=0; i<lena; )
32         {
33             if( pstra[i] == cnt )
34             {
35                 printf( "%s", pstrc ) ;
36                 while( pstra[i] == cnt ) i++ ;
37                 if1 == cnt ) cnt = 2 ;
38                 else cnt = 1 ;
39             }
40             else
41             {
42                 printf( "%c", pstra[i++] ) ;
43             }
44         }
45         printf( "\n" ) ;
46     }
47     return 0 ;
48 }

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