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 }
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 }