这道C语言题怎么做

2025-04-14 22:57:14
推荐回答(3个)
回答1:

#include
void fun(char *a,char *h,char *p)
{
    a=h;
    while ( h<=p ) { if ( *h!='*' ) { *a=*h; a++; } h++; }
    while ( *h ) { *a=*h; a++; h++; }
    *a=0;
}
void main()
{
    char  s[81],*t, *f;
   printf("Enter a string:\n"); gets(s);
   t=f=s;
   while ( *t ) t++; t--;
   while ( *t=='*' ) t--;
   while ( *f=='*' ) f++;
   fun(s,f,t );
   printf("The string after deleted:\n"); puts(s);
}

回答2:

输出结果为 5
因为循环条件为 i<5,也就是循环结束时i=5
要点:不要被循环体内那个 switch-case语句迷惑了

回答3:

这题不会。。。。