很好!
我的电脑出了点问题,修好后学校的网络又出了问题!
我明天给出大答案:因为在linux系统里面!
方寸之内,剖天下; 方坛之内,析自我;
来了!
#include<stdio.h>
void recomment(int c);
void in_comment(void);
void echo_quote(int c);
int
/*romove all comments form a valid c program*/
main()
{
int c;
while((c=getchar())!=EOF)
recomment(c);
return 0;
}
/*recommet :read each character ,remove the commets*/
void recomment(int c)
{
int d;
if(c=='/')
if((d=getchar())=='*')
in_comment();/*beginning comments*/
else
if(d=='/')
{
putchar(c);/*another slash*/
recomment(d);
}
else
{putchar(c);/*not a comment*/
putchar(d);
}
else if(c=='\''||c=='"')
echo_quote(c); /*quote befins*/
else
putchar(c); /*not a comment */
}
/*in_comment:inside of a valid comment */
void in_comment(void)
{
int c,d;
c=getchar(); /*prev character */
d=getchar();/*curr character*/
while(c!='*'||d!='/')/*search for end */
{
c=d ;
d=getchar();
}
}
/*echo_quote:echo characters within quotes*/
void echo_quote(int c)
{
int d;
putchar(c);
while((d=getchar())!=c)/*search for end*/
{
putchar(d);
if(d=='\\')
putchar(getchar());/*ignor escape seq*/
}
putchar(d);
}