问题详情

有以下程序 #include <stdio.h> #include <string.h> void fun(char,*s[],int n) { char *t; int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])) {t=s[i];s[i]:s[j];s[j]=t;} } main() { char *ss[]={"bcc","bbcc","xy","aaaacc","aabcc"}; fun(ss,5); printf("%s,%s ",ss[0],ss[4]); } 程序的运行结果是


A、xy,aaaacc

B、aaaacc,xy

C、bcc,aabcc

D、aabcc,bcc

时间:2022-02-21 17:39 关键词:

答案解析

A
解析:函数fun(char,s[],int n)的功能是对字符串数组的元素按照字符串的长度从小到大排序。在主函数中执行fun(ss,5)语句后,*ss[]={"xy","bcc","bbcc","aabcc","aaaacc"},ss[0],ss[4]的输出结果为xy,aaaacc。