d456.
社辦合併
--
raincole
| From: [203.70.88.138] |
發表日期
:
2011-08-27 21:28
請問為什麼這題我會一直RE呢?
沒程式碼你要我猜你為什麼RE?
#include <iostream>
using namespace std;
char G[100001] , save[100001] , a ,b;
int main(){
int T , len , ptr , counts , B , A , find;
bool finda , findb;
while ( scanf("%d",&T) == 1 ){
gets(G);
while ( T-- ){
find = 0; finda = findb = 0;
gets(G); len = strlen( G );
cin >> a >> b;
ptr = len-1; counts = 0;
while ( 1 ){
if ( G[ptr] == b && !findb){
if ( find == 0 ){
find++; B = ptr;
}
else{
find++; A = ptr;
}
findb = 1;
}
if ( G[ptr] == a && !finda ){
if ( find == 0 ){
find++; B = ptr;
}
else{
find++; A = ptr;
}
finda = 1;
}
if ( find >= 2 ) break;
ptr--;
}
for ( int i = 0 ; i < len ; i++ ){
if ( i == A ){
putchar(a); i++;
while ( i != B )
save[counts++] = G[i++];
putchar(b);
}
else putchar(G[i]);
}
putchar('\n');
G[counts] = 0;
printf( "%s\n",save );
gets( G );
}
}
return 0;
}