有以下程序 #include<stdio.h> #include<string.h> void fun(char*w,int m) {char s,*p1,*p2; p1=w;p2=w+m-1; wh

admin2020-11-23  28

问题 有以下程序
    #include<stdio.h>
    #include<string.h>
    void fun(char*w,int m)
    {char s,*p1,*p2;
     p1=w;p2=w+m-1;
     while(p1<p2){s=*p1;*p1=*p2;*p2=s;p1++;p2--;}}
    main()
     {char a[]="123456";
    fun(a,strlen(a));puts(a);}

选项 A、116611
B、161616
C、654321
D、123456

答案C

解析 函数fun的功能是将字符串w中的元素从大到小进行排列,所以在主函数中调用函数fun后,字符串a的元素从大到小进行了排列。
转载请注明原文地址:https://kaotiyun.com/show/T53p777K
0

最新回复(0)