niusouti.com
更多“下列程序的执行结果是______。in(f(char*s){char*p=s; while(*p!='\0')p++; return(p-s);}main(){ ”相关问题
  • 第1题:

    请读程序: includef(char * s){cahr * p=s;while(* p!='\0')p++;return(p-s);}main(){

    请读程序: # include<stdio.h> f(char * s) {cahr * p=s; while(* p!='\0')p++; return(p-s); } main() {printf("%d\n”,f("ABCDEF"));} 上面程序的输出结果是 ( )

    A.3

    B.6

    C.8

    D.0


    正确答案:B

  • 第2题:

    以下程序的输出结果是()。includeint fun (char*s){char *p=s;while (*p!='\0,) p++

    以下程序的输出结果是( )。 #include<iostream.h> int fun (char*s) { char *p=s; while (*p!='\0,) p++: return (p-s): } void main() { cout<<fun (" ABCDEF ")<<endl: }

    A.3

    B.6

    C.8

    D.0


    正确答案:B

  • 第3题:

    以下程序运行后的输出结果是______。 ss(char*s) { char*p=s; while(*p)p++; return(p-s); } main() { char*a="abded";int i; i=ss(a); printf("%d\n",i); }

    A.8

    B.7

    C.6

    D.5


    正确答案:D

  • 第4题:

    设有如下函数定义。若在主函数中用语句cout<<f("good")调用上述函数,则输出结果为(48)。 int f(char *s){ char *p=s; while(*p! ='\0')p++; return(p-s); }

    A.3

    B.4

    C.5

    D.6


    正确答案:B
    解析:程序中的while循环执行完以后,s指向字符中的第一个元素,p指向'\0'(字符串的末尾位置),所以p-s是字符申的长度。所以选择B。

  • 第5题:

    以下程序运行后,输出结果是()includess(char*s){char*p=s; while(*p)p++ return(p-s);

    以下程序运行后,输出结果是( ) #include<stdio.h> ss(char *s) { char*p=s; while(*p) p++ return(p-s); } main() { char *a="abded" int i; i=ss(a) ; printf("%d\n",i); }

    A.8

    B.7

    C.6

    D.5


    正确答案:D