comment3.c
|
enum
S1, S2, C1, C2
};
int trans[4][0x100];
int state = S1;
void init()
{
int i;
for(i=0;i<0x100;i++){
trans[S1][i] = S1;
trans[S2][i] = S1;
trans[C1][i] = C1;
trans[C2][i] = C1;
}
trans[S1]['/'] = S2;
trans[S2]['/'] = S2;
trans[S2]['*'] = C1;
trans[C1]['*'] = C2;
trans[C2]['*'] = C2;
trans[C2]['/'] = S1;
state = S1;
}
main()
{
unsigned char buf[1000];
unsigned char *s;
init();
while(fgets(buf,1000,stdin)){
for(s=buf;*s;s++){
int oldstate = state;
state = trans[state][*s];
if(oldstate == S2 && state == C1) printf("/*");
if(oldstate == C1 || oldstate == C2) printf("%c",*s);
}
}
}