首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有下列程序: #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
23
问题
有下列程序:
#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://jikaoti.com/ti/jiG0FFFM
本试题收录于:
二级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
下列叙述中正确的是
下列叙述中正确的是
以下叙述中正确的是
设有定义:intk=1,m=2;floatf=7;,则以下选项中错误的表达式是
有以下程序,程序的输出结果是main(){charc1=’A’,c2=’Y’;printf("%d,%d\n",c1,c2);}
有以下程序main(){unsignedchara=2,b=4,c=5,d;d=a|b;d&=c;printf("%d\n",d);}程序运行后的输出结果是
为了建立如图所示的存储结构(即每个结点含两个域,data是数据域,next是指向结点的指针域),则在__________处应填入的选项是Structlink{chardata;___________}node;
若有定义语句:doublex,y,*px,*py;执行px=&x;py=&y;正确的输入语句是
以下不能定义为用户标识符是
随机试题
这个标志是何含义?
妊娠满28周而不满37周分娩为妊娠满28周后胎儿及其附属物娩出为
下列选项中,属于封闭区的是
两组资料中,回归系数b较大的一组
督脉的主要生理功能是
为了减少核定应纳税额的随意性,使核定的数额更接近纳税人实际情况和法定负担水平,税务机关应按以下( )方式进行核定。
甲与乙订立合同后,乙以甲有欺诈行为为由向人民法院提出撤销合同申请,人民法院依法撤销了该合同。根据合同法律制度的规定,下列有关被撤销合同的法律效力的表述中,正确的是()。
根据存货陆续供应和使用模型,下列情形中能够导致经济订货量降低的是()。
我国大陆海岸线北起鸭绿江,南至北仑河口,全长18000公里。()
站在唯理论立场上企图使经验论与唯理论结合,把世界统一在思维基础上的哲学家是()
最新回复
(
0
)