Page 1 of 1

why is ut wrong...

Posted: Tue Jan 31, 2006 3:52 pm
by acmmamun
#include <stdio.h>
#include <string.h>

char in[10000],ch;
int len,t;

int main(){
int i,j,flg;

//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);

while(gets(in)){
len = strlen(in);
flg = 1;
i=0;
while(i<len){
if(in=='!'){
printf("\n");
i++;
}
else if(in>='0' && in<='9'){
if(in[i+1]>='0' && in[i+1]<='9'){
t = (in - '0') + (in[i+1] - '0');
ch = in[i+2];
i+=3;
}
else{
t = in - '0';
ch = in[i+1];
i+=2;
}
for(j=1;j<=t;j++){
if(ch=='b')
printf(" ");
else
printf("%c",ch);
}
}
else{
printf("%c",in);
i++;
}
if(i+1==len && in=='!')
flg = 0;
}
if(flg)
printf("\n");
}
return 0;
}

Posted: Fri Feb 03, 2006 8:19 am
by Wei-Ming Chen
Can you tell me what problem you are writing?