首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include <stdio.h> #include <string.h> void fun(char *s[], int n) { char *t; int i, j
有以下程序 #include <stdio.h> #include <string.h> void fun(char *s[], int n) { char *t; int i, j
admin
2021-07-09
51
问题
有以下程序
#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
) > 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、aaaacc,xy
B、xy,aaaacc
C、bcc,aabcc
D、aabcc,bcc
答案
B
解析
函数fun(char s[ ],int n)的功能是对字符串数组的元素按照字符串的长度从小到大排序,在主函数中执行fun(ss,5)语句后,*ss[]={"xy","bcc","bbcc","aabcc","aaaacc"},ss[0],ss[4]的输出结果为xy,aaaacc。因此B选项正确。
转载请注明原文地址:https://kaotiyun.com/show/Lskp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下定义数组的语句中错误的是
若有定义:inta,b;通过语句scanf("%d;%d",&a,&b);能把整数3赋给变量a,5赋给变量b的输入数据是
以下选项中关于C语言常量的叙述错误的是
有以下程序#include#defineS(x)4*(x)*x+1voidmain(){intk=5,j=2;printf("%d\n",S(k+j));}程序运行后的输
设有定义:doublea[10],*s=a;,以下能够代表数组元素a[3]的是()。
在软件开发中,需求分析阶段可以使用的工具是()。
设序列长度为n,在最坏情况下,时间复杂度为O(log2n)的算法是
在数据管理技术发展的三个阶段中,数据共享最好的是()。
下列二叉树描述中,正确的是()。
公司中有多个部门和多名职员,每个职员只能属于一个部门,一个部门可以有多名职员。则实体部门和职员间的联系是
随机试题
下列()情况不可能是网络电缆故障。
Howcanwegetridofgarbage?Dowehaveenoughenergysourcestomeetourfutureenergyneeds?Thesearetwoimportantque
A、30天B、9个月C、7周D、40天E、3个月乙型肝炎的最长潜伏期为
白花蛇用治风证不包括
云服务是基于互联网的相关服务的增加、使用和交付模式。我们经常使用的Gmail、网上相册等属于(20)。
下列叙述中,正确的是()。
Lookatthenotesbelow.Someinformationismissing.Youwillhearaconversationaboutmakingtravelarrangements.Foreachqu
()yourvaluablehelp,wecouldn’thavefinishedtheexperimentaheadoftime.
AttheuniversityMr.Robinsonspecializedin______.
Marketplaceorpeer-to-peer(P2P)lendingmatchesborrowersandlendersonlow-costonlineplatforms.Byskirtingbanks,P2Plendi
最新回复
(
0
)