首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include <stdio.h> #include <string.h> void fun(char s[ ][10],int n) { char t; int i,j; for(i=0;i<n-1;i+ +) for(j=i+1;j<n;
有以下程序 #include <stdio.h> #include <string.h> void fun(char s[ ][10],int n) { char t; int i,j; for(i=0;i<n-1;i+ +) for(j=i+1;j<n;
admin
2019-08-10
20
问题
有以下程序
#include <stdio.h>
#include <string.h>
void fun(char s[ ][10],int n)
{ char t; int i,j;
for(i=0;i<n-1;i+ +)
for(j=i+1;j<n;j+ +)
if(s
[0]>s[j][0]){t=s
[0];s
[0]=s[j][0];s[j][0]=t;}
}
main( )
{ char ss[5][10]={"bcc","bbcc","xy","aaaacc","aabcc"};
fun(ss,5); printf("%s,%s\n",ss[0],ss[4]);
}
程序的运行结果是
选项
A、aaaacc,xy
B、bcc,aabcc
C、xy,aaaacc
D、aabcc,bcc
答案
C
解析
函数fun(char s[ ][ 10],int n)通过两重for循环语句,比较二维字符数组s[ ][ 10]的每个字符串的首字符大小,如果前一个字符串首字符大于后一个字符串的首字符,则交换这两个字符串的首字符。在主函数中,语句fun( ss,5)的作用是对二维字符数组ss[5][10]的5个字符串的首字符进行从小到大的排序,不影响各个字符串另外的字符。所以排序结束后,5个字符串的第一个字符依次变为a、a、b、b和x;最后输出第1个和第4个字符串。
转载请注明原文地址:https://kaotiyun.com/show/ZgRp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
若有以下程序#includevoidsp(int*a){intb=2;a=&b;*a=*a*2;printf("%d,",*a);}main(){intk=3,*p=&k;sp(p);printf("%d,%d\n",k,*p);}则程
我们所写的每条C语句,经过编译最终都将转换成二进制的机器指令。关于转换以下说法错误的是
下面不属于软件设计阶段任务的是
有满足实体完整性约束的条件下( )。
某二叉树有5个度为2的结点,则该二叉树中的叶子结点数是()。
一间宿舍可住多个学生,则实体宿舍和学生之间的联系是( )。
一个工作人员可以使用多台计算机,而一台计算机可被多个人使用,则实体工作人员与实体计算机之间的联系是( )。
一个工作人员可以使用多台计算机,而一台计算机可被多个人使用,则实体工作人员与实体计算机之间的联系是()。
对下列二叉树进行前序遍历的结果是
随机试题
—DidyougetanyinformationfromMr.Lee?—He________anexpert,buthedoesn’tseemtoknowmuch.
指针式万用表正确操作时,是应水平放置,还是垂直放置?
小儿厌食脾失健运证的治法是()
下列说法正确的是:
关于法官公正和廉洁的要求,下列说法正确的是:()
根据《中华人民共和国证券法》规定,申请上市的基金必须具备的条件有()。
下列关于内蒙古说法正确的是()。
根据《社会救助暂行办法》,县级以上地方人民政府应当发挥社会工作服务机构和社会工作者的作用,为社会救助对象提供专业服务,这些专业服务不包括()。
ItissaidthatGeorgeWashingtonwasoneofthefirsttorealizehowimportantthebuildingofcanalswouldbetothenation’s
Nowhereinnatureisaluminumfoundfree,owingtoitsalways______withotherelements,mostcommonlywithoxygen.
最新回复
(
0
)