有以下程序 #include #include void fun(char *s[], int n) { char *t; int i, j; for (i=0; i

admin2015-07-28  26

问题 有以下程序
#include
#include
void fun(char *s[], int n)
{ char *t; int i, j;
for (i=0; ifor (j=i+1; jif (strlen(s) > strlen(s[j]))
{ t = s; s = s[j]; s[j] = t; }
}
main()
{ char *ss[]={"bcc","bbcc","xy", "aaaacc", "aabcc"};
fun(ss, 5); printf("%s,%s\n", ss[0],ss[4]);
}
程序的运行结果是( )。

选项 A、xy,aaaacc
B、aaaacc,xy
C、bcc,aabcc
D、aabcc,bcc

答案A

解析 函数fun()的功能是字符串数组s中的字符串依照其字符串长度从小到大排列,所以被调函数"fun(ss, 5); "执行完毕后,字符串数组ss为{"xy", "bcc", "bbcc", "aabcc", "aaaacc"},所以输出结果为选项A)。
转载请注明原文地址:https://kaotiyun.com/show/AzDp777K
0

最新回复(0)