我希望你是我独家记忆

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

URAL_1654

Posted on 2008-12-14 02:02 Hero 阅读(127) 评论(0)  编辑 收藏 引用 所属分类: 代码如诗--ACM
 1 // 1654 C++ Accepted 0.031 333 KB URAL
 2 
 3 //边输入边处理
 4 //其实类似于栈的性质--每次去掉栈顶两个相同的元素,然后添加新元素
 5 
 6 #include "stdio.h"
 7 #include "stdlib.h"
 8 #include "string.h"
 9 
10 char str[250000] ;
11 
12 int main()
13 {
14     int pstr = 0 ;
15     while( scanf( "%c"&str[pstr] ) != EOF )
16     {
17         if'\n' == str[pstr] ) break ;
18         if( pstr-1 >=0 && str[pstr-1]==str[pstr] )
19         {
20             pstr-- ;
21         }
22         else pstr++ ;
23     }
24 
25     forint i=0; i<=pstr; i++ ) printf( "%c", str[i] ) ;
26     //printf( "\n" ) ;
27 
28     return 0 ;
29 }

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