niusouti.com
更多“以下程序输出的结果是 #include<stdio.h> #include<string.h> main() { char w[][10 ”相关问题
  • 第1题:

    以下程序的输出结果是______。includeincludefun(char *w,int n){ char t,*

    以下程序的输出结果是______。 #include<stdio.h> #include<siring.h> fun(char *w,int n) { char t,*s1,*s2; s1=w;s2=w+n-1; while(s1<s2) { t=*s1++; *s1=*s2-; *s2=t; } } main() { char *p; p="1234567"; fun(p,strlen(p)); puts(p); }

    A.1234567

    B.7654321

    C.1711717

    D.7177171


    正确答案:C
    解析:在子函数fun中,s1为字符串w的起始地址,s2为字符串的结束地址(字符'\0'除外),当执行循环结束循环,w=“1711717”。

  • 第2题:

    以下程序的输出结果是_______。includeincludefun(char*w,int n){char t,*s

    以下程序的输出结果是_______。 #include<stdio.h> #include<string.h> fun(char*w,int n) { char t,*s1,*s2; s1=w;s2=w+n-1; while(s1<s2) { t=*s1++: *sl=*s2-; *s2=t; } } main() { char*p; p="1234567"; fun(p,strlen(p)); puts(p); }

    A.1234567

    B.7654321

    C.1711717

    D.7177171


    正确答案:C
    解析:在于函数fun中,s1为字符串w的起始地址,s2为字符串的结束地址(字符'\0'除外),当执行循环结束循环,w="1711717"。

  • 第3题:

    有以下程序:include include main(){char *p[10]={"abc","aabdfg","dcdbe"

    有以下程序: #include <stdio.h> #include <string.h> main() { char *p[10]={"abc","aabdfg","dcdbe","abbd","cd"}; printf("%d\n",strlen(p[4])); } 执行后的输出结果是( )。

    A.2

    B.3

    C.4

    D.5


    正确答案:A
    解析:p是由10个指向字符型数据的指针元素组成的指针数组,其中前5个数组元素进行了初始化。p[4]="cd",strlen(str)是统计字符串str中字符的个数(不包括终止符'\0'),输出结果为2。

  • 第4题:

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

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

    A.8

    B.7

    C.6

    D.5


    正确答案:D

  • 第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

  • 第6题:

    以下程序的输出结果是【 】。includeincludechar*fun(char*t){ char *p=t;retur

    以下程序的输出结果是【 】。

    include <stdio.h>

    include <string.h>

    char *fun(char *t)

    { char *p=t;

    return (p+strlen(t)/2);

    }

    main()

    { char *str="abcdefgh";

    str=ftm(str);

    puts(str);

    }


    正确答案:
    efgh 解析:本题考查的知识点是:字符指针。题目中的fun()函数,通过strlen()库函数得到形参t所指字符串的长度。然后返回t所指字符串首地址值加上该长度值的一半。所以fun()函数的作用就是返回所给字符串的中间位置。故最后通过puts()输出的字符串为"efgh"。