以下程序用以删除字符串中所有的空格,请填空。
include<stdio.h>
main()
{char s[100]={"Our teacher teach C language!"};int i,j;
for(i=j=0;s[i]!='\0';i++)
if(s[i]!=''){( )}
s[j]='\0';
printf("%s\n",s);
}
第1题:
22、删除字符串的所有前导空格,请完善程序。 #include <stdio.h> void f1(char *s) { char *t; t=________; while(*s==' ') s++; while(*t++=*s++); } int main() { char str[80]; gets(str); f1(str); puts(str); return 0; }
第2题:
删除字符串的所有前导空格,请完善程序。 #include <stdio.h> void f1(char *s) { char *t; t=________; while(*s==' ') s++; while(*t++=*s++); return; } int main() { char str[80]; gets(str); f1(str); puts(str); return 0; }
第3题:
删除字符串的所有前导空格,请完善程序。 #include <stdio.h> void f1(char *s) { char *t; t=________; while(*s==' ') s++; while(*t++=*s++); } int main() { char str[80]; gets(str); f1(str); puts(str); return 0; }
第4题:
以下程序用以删除字符串中所有的空格,请填空。
inculde <stdio.h>
main()
{ char s[100]=(“our teacher teach c language!”);int I,j;
For(i=j=0;s[i]!=’’)
iF(s[i];s[i]!=’\0’) {s[j]=s[i];j ++}
s[j]=【 】
printF(“index=%d\n”,s-a);
}
第5题:
请读程序: # includde<stdio.h> # include<string.> void fun(char * s) {char a[10]; strcpy(a,"STRING"); s=a; } main() { char*p; fun(p); print{("%s\n",p); } 上面程序的输出结果(表示空格) ( )
A.STRING
B.STRING
C.STRING
D.不确定的值
第6题:
以下程序用以删除字符串中所有的空格,请填空。
第7题:
有以下程序: #include<stdio.h> void fun(char**p) { ++P;printf("%s\n",*p);} main() char*a[]={"Morning","Afternoon","Evening","Night"}; fun(A); } 程序的运行结果是( )。
A.Afternoon
B.fternoon
C.Morning
D.oring
第8题:
请补充函数fun(),该函数的功能是:依次取出字符串中所有的小写字母以形成新的字符串,并取代原字符串。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
include<conio.h>
void fun(char *s)
{
int i=0;
char *p=s;
while(【 】)
{
if (*p>='a'&&*p<='z')
{
s[i]=*p;
【 】;
}
p++;
}
s[i]=【 】;
}
main()
{
char str[80];
clrscr();
printf("\nEnter a string:");
gets(str);
printf("\n\nThe string is:\%s\n",str);
fun(str);
printf("\n\nThe string of changing
is:\%s\n",str);
}
第9题:
( 14 )以下程序用以删除字符串所有的空格,请填空。
#include <stdio.h>
main ()
{ char s[100]={ " Our teacher teach C language! " };int i,j;
for ( i=j=0;s[i]!= ’ \0 ’ ;i++ )
if ( s[i]!= ‘ ’ ) {s[j]=s[i];j++;}
s[j]= 【 14 】
printf ( " %s\n " ,s ) ;
}