A: HelloNEU
B: Hello
C: NEU
D: 输出为空
举一反三
- 中国大学MOOC: 下面程序 char * fun1(char *t,char *s){ while(*t=*s){s++,t++;} return t;}int main(){ char a[100]=Hello; char b[20]=NEU; char *t=NULL; t=fun1(a,b); printf(%s,t);}执行结果为
- 对于如下程序:#include [stdio.h] int s(char *,char *); int main(){ char a[20]; char b[10]; char *p; char *q; int i; p=a; q=b; scanf("%s%s",a,b); i=s(a,b); printf("%d",i);} int s(char *s,char *t){ while(*s!='\0' && *t!='\0'){ if(*s= =*t){ s++; t++; } else return *s-*t; } return *s-*t;}如果输入流是12 13,程序的输出是什么? A: -1 B: 1 C: 0 D: 2
- 以下与库函数strcmp(char *s,char *t)功能相等的程序段是( )。? int strcmp3(char *s,char *t){ for ( ; *t==*s; ) { if (!*t) return 0 ; t++ ; s++ ; } return (*s-*t) ;}|int strcmp2(char *s,char *t){ for ( ; *s++==*t++; ) if (!*s) return 0 ; return (*s-*t) ;}|int strcmp1(char *s,char *t){ for ( ; *s++==*t++; ) if (*s=='\0') return 0 ; return (*s-*t) ;}|int strcmp4(char *s,char *t){ for ( ; *s==*t;s++,t++ ) if (!*s) return 0 ; return (*t-*s) ;}
- 智慧职教: 下面函数fun的功能是( )。 int fun(char *s,char *t) { while(*s==*t) if(*s=’\\0’) return 0; else s++,t++; return *s-*t; }
- 下列不能输出字符串"Hello"的程序段是______。 A: char *t; t="Hello";printf("%s\n",t); B: char *t, s[]="Hello"; t=s;printf("%s\n",t); C: char s[20],*t=s; t="Hello";printf("%s\n",s); D: char *t, s[]="Hello"; t=s;printf("%s\n",s);
内容
- 0
函数fun的功能是: int fun(char *s){ char *t=s; while(*t++); return (t-s); }
- 1
中国大学MOOC: 有以下函数int fun(char t[],char s[]){ int i=0; while(s[i]!=0) t[i]=s[i++]; t[i]=; return i;}执行如下代码片段后 char s[]=NameLI; char t[100]; fun(t,s); printf(%s,t); 程序运行后的输出结果是[/i][/i][/i]
- 2
有以下函数int fun(char t[],char s[]){ int i=0; while(s[i]!=0) t[i]=s[i++]; t[i]='\0'; return i;}执行如下代码片段后 char s[]="Name\0LI"; char t[100]; fun(t,s); printf("%s",t); 程序运行后的输出结果是[/i][/i][/i] A: Name\0LI B: NameLI C: Name D: LI
- 3
有下列程序,程序运行后的输出结果是( )。 #include void fun(char *a,char *b) { while (*a=='*') a++; while(*b=*a) { b++; a++;} } int main() { char *s='****a*b****',t[80]; fun(s,t); puts(t); return 0; }
- 4
有以下函数 int fun(char *s) { char *t=s; while(*t) t++; return(t-s); } 该函数的功能是( ).