Posted on 2008-12-14 02:02
Hero 閱讀(136)
評論(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 for( int i=0; i<=pstr; i++ ) printf( "%c", str[i] ) ;
26 //printf( "\n" ) ;
27
28 return 0 ;
29 }