以下与库函数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) ;}
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; }
- 对于如下程序:#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
- 以下函数的功能对应于 。[br][/br]int fun(char *s, char *t) {[br][/br]while( (*s)&&(*t)&&(*t==*s)){[br][/br]t++;[br][/br]s++;[br][/br]}[br][/br]return(*s-*t);[br][/br]} A: strlen(s)+strlen(t) B: strcmp(s,t) C: strcpy(s,t) D: strcat(s,t)
- 中国大学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);}执行结果为
- 有以下函数 int fun(char *s) { char *t=s; while(*t) t++; return(t-s); } 该函数的功能是( ).