niusouti.com

下列程序运行后,输出结果是______。 include include fun(char *w ,int下列程序运行后,输出结果是______。 #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++; *s1=*s2--; *s2=t; } } main () { char *p; p="1234567"; fun

题目
下列程序运行后,输出结果是______。 include include fun(char *w ,int

下列程序运行后,输出结果是______。 #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++; *s1=*s2--; *s2=t; } } main () { char *p; p="1234567"; fun (p, strlen (p)); puts (p); }

A.1234567

B.7654321

C.1711717

D.7177171


相似考题
更多“下列程序运行后,输出结果是______。 #include <stdio. h> #include <string. h> fun(char *w ,int ”相关问题
  • 第1题:

    以下程序的输出结果是_______。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"。

  • 第2题:

    以下程序的输出结果是()。includeint fan(int);main(){int w=5; fun(w);printf("\n");}

    以下程序的输出结果是( )。 #include <stdio.h> int fan(int); main() { int w=5; fun(w); printf("\n"); } fun(int k) { if(k>0) fun(k-1); printf("%d",k); }

    A.5 4 3 2 1

    B.0 1 2 3 4 5

    C.1 2 3 4 5

    D.5 4 3 2 1 0


    正确答案:B
    解析:本题考查函数的递归调用。fun函数共被调用6次,即fun(5)、fun(4)、fun(3)、fun(2)、fun(1)、fun(0),其中fun(5)是main函数调用的,其余是在fun函数中调用的。

  • 第3题:

    以下程序运行后的输出结果是() 。   #include <stdio.h>   #include <stdlib.h>   #include <string.h>   main()   { char *p; int i;    p=(char *)malloc(sizeof(char)*20);    strcpy(p,"welcome");    for(i=6;i>=0;i--) putchar(*(p+i));    printf("n"); free(p);   }


    D 本程序中通过DATA语句对数组B赋值的结果为矩阵DO循环语句的功能是将数组B的第2列的元素的值依次赋值给数组A。因此,A(1)=4、A(2)=5、A(3)=6,所以格式输出数组A后输出的结果为456。

  • 第4题:

    下面程序的运行结果是______。 include include fun(char*w,int n) { char

    下面程序的运行结果是______。 #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++;*s1=*s2--;*s2=t;} } main() { char*p; p="1234567"; fun(p,strlen(p)); puts(p); }

    A.7654321

    B.1714171

    C.1711717

    D.7177171


    正确答案:C

  • 第5题:

    以下程序的输出结果是【 】。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"。