潜水的大虾帮帮忙
#include <stdio.h>#define COPY 0
#define START 1
#define COMMENT 2
#define END 3
void main (void)
{
char c;
int state=COPY;
printf("please input a text end of Ctrl+z:\n");
while((c=getchar())!=EOF)
{
switch(state)
case COPY: if(c=='/') state=START;
else putchar(c);
break;
case START:
if(c=='*') state=COMMENT;
else {
putchar('/');
state=(c=='/')?START:(putchar(c),COPY);
}
break;
case COMMENT:
if(c=='*') state=END;
break;
case END: if(c=='/') state=COPY;
else c=='*'?state=END:state=COMMENT;
}
}