niusouti.com

下面程序的输出结果是( )。#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(){ static char p[]="1234567";fun(p,strlen(p));printf("%s",p);}A.7654321 B.1717171 C.7171717 D.1711717

题目

下面程序的输出结果是( )。#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(){ static char p[]="1234567";fun(p,strlen(p));printf("%s",p);}A.7654321 B.1717171 C.7171717 D.1711717


相似考题
参考答案和解析
正确答案:D
函数的功能是将数组的元素交换,首先s1=p,即s1指向1,s2=p+7-1,即s2指向7,t=*s1++,将1赋给t,然后s1指向2,*s1=*s2++,将7赋给s1,即原来2的位置,s2指向6,然后*s2=t,将1赋给*s2即原来6的位置,…….
更多“下面程序的输出结果是( )。#include "string.h"fun(char*w,int n){ char t,*s1,*s2;s1=w; s2=w+n- ”相关问题
  • 第1题:

    下面程序的运行结果是()。includeincludemain(){char*s1="abDuj";char*s2="

    下面程序的运行结果是( )。 #include<stdio.h> #include<string.h> main() {char*s1="abDuj"; char*s2="ABdUG"; int t; t=strcmp(s1,s2); printf("%d",t); }

    A.正数

    B.负数

    C.零

    D.不确定的值


    正确答案:A

  • 第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 main() {char*s1,*s2,m; s1=s2=(char*)malloc(size

    以下程序的输出结果是( )。

    include<stdlib.h>

    main()

    {char*s1,*s2,m;

    s1=s2=(char*)malloc(sizeof(char));

    *s1=15;

    *s2=20;

    m=*s1+*s2:

    printf("%d\n",m);

    }


    正确答案:40
    40 解析:malloc()函数的作用是开辟一个长度为sizeof(char)的内存区,s1、s2为指向字符型数据的指针变量,执行“s1=s2=(char*)malloc(sizeof(chat));”语句后,s1、s2指向同一个存储空间,此时m=*s1+*s2=20+20=40。

  • 第4题:

    下列程序运行后,输出结果是______。 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


    正确答案:C

  • 第5题:

    下面程序的运行结果是______。 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