• 2022-06-09
    以下不能将s所指字符串正确复制到t所指存储空间的是( )
    A: do{*t++=*s++;}while(*s );
    B: for(i=0;t[i]=s[i];i++);
    C: while(*t=*s){t++;s++}
    D: for(i=0,j=0;t[i++]=s[j++]; );
  • A

    内容

    • 0

      下面函数的功能是________。 sss(char *s, char *t) { int i=0;while( t[i]){ s[i]=t[i]; i++ ; } s[i]= '\0'; }? 求字符串的长度|比较两个字符串的大小|将字符串s复制到字符串t中|将字符串t复制到字符串s中

    • 1

      下面程序的时间复杂为() for(i=1,s=0; i<=n; i++) {t=1;for(j=1;j<=i;j++) t=t*j;s=s+t;}

    • 2

      程序填空: 以下程序中,函数fun的功能是:将数组s中的所有素数复制到数组t中。 例如:当数组s中值为:21,17,9,59,77,67,49,99,35,83时,则数组t中的值应为:17,59,67,83。 #include void fun(int s[],int t[]) { int i,j,k,y=0; for(i=0;i<=9;i++) { k=s[i]/2; /************found************/ for(j= ____1____ ; j<=k; j++) if(s[i]%j==0) break; /************found************/ if(j ____2____ k) { /************found************/ t[ ____3____ ]=s[i]; } } t[y]=0; } main() { int i,s[10]={21,17,9,59,77,67,49,99,35,83}, t[10]; fun(s, t); for(i=0;t[i]!=0;i++)printf("%d ", t[i]); printf(" "); }

    • 3

      以下与库函数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) ;}

    • 4

      与while(*s++=*t++);等价的程序段是A.do {     *s = *t++;  } while ( *s++ );B.while ( *t )    *s++ = *t++;C.do {     *s++ = *t++;  } while ( *t  );D.while ( *s )     *s++ = *t++;