首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include <stdio.h> #include <string.h> typedef struct { char name[9]; char sex; float score[2]; } S
有以下程序 #include <stdio.h> #include <string.h> typedef struct { char name[9]; char sex; float score[2]; } S
admin
2013-02-23
62
问题
有以下程序 #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", T, 95.0, 92.0}, d; d=f(c); printf("%s,%c,%2.0f,%2.0f\n", d.name, &sex, &score[O], d.score[1]); } 程序的运行结果是
选项
A、Qian, f,95,92
B、Qian,m,85,90
C、Zhao,m,85,90
D、Zhao,f,95,92
答案
C
解析
本题的f()函数中,首先定义了一个STU结构体变量b并初始化为{"Zhao",’m’,85.0,90.0},然后分别通过strcpy()库函数、赋值语句和for循环,将b中所有成员分别赋给形参a的相应成员,最后返回a。所以,无论传递给函数fun()的参数是什么,结果返回的都会是函数中定义的STU结构体b的内容{"Zhao",’m’,85.0,90.0}。故最终输出结果为:Zhao,m,85,90,应该选择C。
转载请注明原文地址:https://kaotiyun.com/show/6SPp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序:#include<stdio.h>voidfunl(char*p){char*q;q=p;while(*q!=’\0’)}(*q)++;q++;}mains(){chara[]={
以下叙述中错误的是()。
有以下程序:#include<stdio.h>main()char*p[]={"3697","2548"};inti,j;longnum=0;for(i=0;i<2;i++){
有以下程序:#include<stdio.h>intfun(intx[],intn){staticintsum=0,i;for(i=0;i<n;i++)sum+=x[i];returnsum
设fp为指向某二进制文件的指针,且已读到此文件末尾,则函数feof(fp)的返回值为()。
有以下程序段:structst{intx;int*y;}*pt;inta[]={1,2},b[]={3,4};structstc[2]={10,a,20,b};pt=c;以下选项中表达式的值为
有以下程序:#include<stdio.h>intfun(intn){if(n==1)return1;elsereturn(n+fun(n-1));}main(){intx;seanf("%
下列程序的输出结果是()。main{intx=i,y=8;printf("%d%d\n",x--,--y);
若有以下结构体定义,则是正确的引用或定义。Structexample{intx;inty;}V1;
随机试题
A、Heisahabitualcriminal.B、Hewasaccusedoffamilyviolence.C、Hewaswronglyimprisoned.D、Hehasbittermemoriesofchild
普通旋转阳极X线管阳极启动时间一般在
人造象牙的主要成分是,它是经加聚反应制得的。合成此高聚物的单体是:
分税制的主要标志之一是对地方收支的计算采取( ),以取代过去的“基数法”。
下列关于固定资产初始计量的表述中,正确的有()。
他想过一种无忧无虑的生活。
Aslongaswearealive,wearelearningand,infact,someofourmostimportantlearningtakesplaceoutsideofschool______in
Butforthepoorweatherourtriptothewildwouldbeaveryexcitingone.
()集合包装()物流管理()销售物流()泡沫经济
A、Heworksatanationalpark.B、Heisaqueenbeespecialist.C、Heremovedthebeesfromtheboot.D、Hedrovethebeesawayfro
最新回复
(
0
)