首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有下列程序: #include<stdio.h> #include<string.h> typedef struct{char name[9];char sex;float score[2];}STU; STU f(STU a) {STU b={"Zhao
有下列程序: #include<stdio.h> #include<string.h> typedef struct{char name[9];char sex;float score[2];}STU; STU f(STU a) {STU b={"Zhao
admin
2020-03-15
46
问题
有下列程序:
#include<stdio.h>
#include<string.h>
typedef struct{char name[9];char sex;float score[2];}STU;
STU f(STU a)
{STU b={"Zhao",’m’,85.0,90.0};int i;
strcpy(a.name,b.name);
a.sex=b.sex;
for(i=0;i<2;i++)a.score
=b.score
;
return a;}
main()
{STU c={"Qian",’f’,95.0,92.0},d;
d=f(c);pfintf("%s,%c,%2.0f,%2.0f\n",d.neme,d.sex,d.score[0],d.score[1]);
}
程序的运行结果是
选项
A、Qian,m,85,90
B、Zhao,f,95,92
C、Zhao,m,85,90
D、Qian,f,95,92
答案
D
解析
f()函数的功能是对形参a的各个成员用结构体变量b的各个成员进行赋值后,然后返回变量a。在主函数中调用f(c)函数时,将STu类型的结构体变量c的值传递给形参a,函数f()在对a的各个成员进行重新赋值后,再将返回变量a的值传给d,最后输出结构变量d的各个成员的值。
转载请注明原文地址:https://kaotiyun.com/show/iDCp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
若有以下程序#include<stdio.h>main(){inta=1,b=2,c=3,d=4;if((a=2)‖(b=1))c=2;if((c==3)&&(d=-1))a=5;printf("%d
下列叙述中正确的是
C语言主要是借助以下哪种手段来实现程序模块化
以下叙述中正确的是
下列叙述中正确的是
设有定义:intk=1,m=2;floatf=7;,则以下选项中错误的表达式是
变量a中的数据用二进制表示的形式是01011101,变量b中的数据用二进制表示的形式是11110000.若要求将a的高4位取反,低4位不变,所要执行的运算是
有以下程序main(){unsignedchara=2,b=4,c=5,d;d=a|b;d&=c;printf("%d\n",d);}程序运行后的输出结果是
若有定义语句:inta[2][3],*p[3];,则以下语句中正确的是
随机试题
《声声慢》是一首慢词,婉约词,是作者前期词的代表作品。()
下列情况中,交割仓库应承担赔偿责任的有()。
1689年《权利法案》颁布的主要意义在于()。
如果你打算拍一部以18世纪的英国为背景的影片,下列不可能在影片中出现的情景是()。
AftertheWarofIndependence,Americansdesignedanewsystem.Whatit?
Therearevariouswaysinwhichindividualeconomicunitscaninteractwithoneanother.Threebasicwaysmaybedescribedasth
A、Stomachcancer.B、Skincancer.C、Lungcancer.D、Bloodcancer.AA是老师提到阳光可以防御癌症后列举的例子之一。B是曝晒导致的。
A、Seeifhequalifiesforastudentloan.B、Makeaproposaltothegovernment.C、Starttosaveuptopayforhiskidstogotos
FootballandMoneyWhywasitfootball,ratherthantheothergreatVictoriansports,thatcapturedtheworld?Onereasonma
A、Whethertoaccepthisboss’sjoboffer.B、Whethertoapplytotransfertoanotherplace.C、Whethertofindanewjob.D、Whethe
最新回复
(
0
)