首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有下列程序: #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
18
问题
有下列程序:
#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全国计算机二级
相关试题推荐
下列叙述中正确的是
以下关于C语言的叙述中正确的是
下列叙述中正确的是
以下叙述中正确的是
以下叙述中错误的是
设有定义:intk=1,m=2;floatf=7;,则以下选项中错误的表达式是
若有定义语句:inta[2][3],*p[3];,则以下语句中正确的是
随机试题
当砂轮直径大于或等于()mm时,则砂轮装上法兰后应先进行静平衡。
下列与产生组织液的有效滤过压无关的是
男,9岁,体重25kg,烧伤3小时入院,烧伤总面积80%,其中深Ⅱ度30%、Ⅲ度50%,伤后无尿,心率150次/分,呼吸36次/分,伤后8小时输液2500ml(其中胶体600ml)后仍无尿。伤后第8天,体温39.8℃,心率148次/分,呼吸36次/分,创面
最好发于吸烟者的肺部恶性肿瘤是
关于促胃液素的叙述,正确的是()
某市政设施工程全部由政府投资兴建。该项目为该省建设规划的重点项目之一,且已列入地方年度固定投资计划,概算已经主管部门批准,征地工作尚未全部完成,施工图纸及有关技术资料齐全。现决定对该项目进行施工招标。招标人在国家级报刊发布招标公告。因估计除本市施工企业参加
现在的古建筑根据社会功能可以划分为宫殿建筑、礼制建筑、民居建筑、宗教建筑、风水建筑、园林建筑、工程建筑等。()
下列选项中,与“李白和王维是唐朝诗人”判断不同的是()。
设a,b,c为整型数,且a=2,b=3,c=4,则执行完以下语句后,a的值是【】。a*=16+(b++)-(++c);
Researcherswhorefusetosharedatawithothersmay【31】otherstowithholdresultsfromthem,【32】astudybyhealth-policyanalys
最新回复
(
0
)