单选题有以下程序:#include #include typedef struct{ char name[10]; char sex; int age;}STU;void fun(STU t){ strcpy(t.name,Tong); t.age++;}main(){ STU s[2] = {Hua, 'm', 18, Qin, 'f', 19}; fun(s[1]); printf(%s,%d,%s,%d, s[0].name, s[0].age, s[1].name, s[1].age);}程序运行后的输出结果是( )。AHua,19,Tong,19BHua,18,Tong,20CTong,19,Qin,19DHua,19,Tong,19
单选题
有以下程序:#include #include typedef struct{ char name[10]; char sex; int age;}STU;void fun(STU t){ strcpy(t.name,Tong); t.age++;}main(){ STU s[2] = {Hua, 'm', 18, Qin, 'f', 19}; fun(s[1]); printf(%s,%d,%s,%d, s[0].name, s[0].age, s[1].name, s[1].age);}程序运行后的输出结果是( )。
A
Hua,19,Tong,19
B
Hua,18,Tong,20
C
Tong,19,Qin,19
D
Hua,19,Tong,19
参考解析
解析:
程序执行过程为:定义STU类型数组,长度为2,并为其初始化。调用函数fun(s[1])将变量s[1]值传入函数,则t.name= "Qin",t.sex= 'f',t.age = 19。调用函数strcpy使t.name = "Tong",t.age = 20,函数调用结束。注意值传递时对形参的操作不会改变实参的值,结构体数组中元素并没有发生改变,答案选择D选项。
程序执行过程为:定义STU类型数组,长度为2,并为其初始化。调用函数fun(s[1])将变量s[1]值传入函数,则t.name= "Qin",t.sex= 'f',t.age = 19。调用函数strcpy使t.name = "Tong",t.age = 20,函数调用结束。注意值传递时对形参的操作不会改变实参的值,结构体数组中元素并没有发生改变,答案选择D选项。
相关考题:
根据下列定义,能打印出字母P的语句是( )。struct stu{char name[10];int age;};struct stu s[10]={"John",11,"Pau1",12,"Mary",11,"adam",12};A.primf("%c",s[3].name};B.primf("%c",s[3].name[1]);C.printf("%c",s[2].name[1]);D.printf("%c",s[1].name[0]);
根据下列的定义,能打印出字母P的语句是( )struct stu {char name[10];int age;};stmct stu s[10]={"John",11,"Paul",12,"Mary",11,"adam",12}:A.printf("%c",s[3].name);B.printf("%c",s[3].name[1]);C.printf("%c",s[2].name[11]);D.printf("%c",s[1].name[0]);
有以下程序:#includestruct stu { int num;char name[10];int age;}void fun(struct stu*p){ printf(%s\n,(*p).name);}main{ struct stu students[3]={{9801,Zhang.20}, {9802,Wang,19},{9803,Zhao,1 8}}fun(students+2); }输出的结果是( )。A.ZhangB.ZhaoC.WangD.18
有以下程序includestruct STU{char name[10];int num;};void f(char*name, intnum){s 有以下程序 #include <string.h> struct STU { char name[10]; int num; }; void f(char *name, int num) { struct STU s[2]={{"SunDan",20044},{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() { struct STU s[2]={{"YangSan",20041},{"LiSiGuo",20042}},*p; p=s[1]; f(p->name,p->num); printf("%s %d\n",p->name,p->num); } 程序运行后的输出结果是A.SunDan 20042B.SunDan 20044C.LiSiGuo 20042D.YangSan 20041
有以下程序: struct STU { char name[10]; int num; float TotalScore; }; void f(struct STU *p) { struct STU s[2]={{"SunDan", 20044, 550}, {"Penghua", 20045, 537}}, *q=s; ++p; ++q; *p=*q; } main() { struct STU s[3]={{"YangSan", 20041, 703}, {"LiSiGuo", 20042, 580}}; f(s); printf(" % s % d % 3.0f\n", s[1]. name, s[1]. num, s[1]. TotalScore); } 程序运行后的输出结果是______。A.SunDan 20044 580B.Penghua 20045 537C.LiSiGUO 20042 580D.SunDan 20041 703
有以下程序: include struct STU (char name[10]; int num; }; 有以下程序: #include <string.h> struct STU (char name[10]; int num; }; void f(char *name, int num) {struct STU s[2]={{"SunDan",20044}.{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() {struct STU s[2]={{"YangSall",20041},{"LiSiGao",20042}},*p;p=s[1]; f(p->name,p->num); printf("%s%d\n",p->name,p->num); } 程序运行后的输出结果是 ______。A.SunDan 20042B.SunDan 20044C.LiSiGuo 20042D.YangSan 20041
有以下程序 include include typedef struct { cha 有以下程序 #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[i] = b.score[i]; 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,92B.Qian,m,85,90C.Zhao,m,85,90D.Zhao,f,95,92
有以下程序#include stdio.hstruct stu{ int num; char name [10];int age;};Void fun(struct stu *p){ printf("%s\n,p-name);}main( ){ struct stu x[3]={ {01,”Zhang”,20},{02, ” Wang”,19},{03, ”zhao”,18} };fun(x+2);}程序运行后的输出结果是A)ZhangB)ZhaoC)WangD)19
根据下列的定义,能打印出字母P的语句是( )。 struct stu { char name[10]; iht age; }; struct stu s[10]={"John",11, "Paul", 12, "Mary", 11, "adam",12 };A.printf("%c",s[3].name);B.printf("%c",s[3].name[1]);C.printf("%c",s[2].name[1]);D.printf("%c",s[1].name[0]);
有以下程序: #includestdio.h struct stu { int num;char name[l0];int age;}; void fun(struct stu*p) { printf("%s\n",p-name);} main( ) { struct stu x[3]={{01,"Zhang",20),{02,"Wang",l9},{03,"Zha0",l8}}; fun(x+2); } 程序运行后的输出结果是( )。A.ZhangB.ZhaoC.WangD.19
有以下程序 include include typedef stmct{ char name[9];char sex;flo 有以下程序#include <stdio.h>#include <string.h>typedef stmct{ char name[9];char sex;float score[2];}STU;void 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[i]=b.score[i];main( ){ STU c={"Qian",'f',95.0,92.0};f(c);printf("%s,%c,%2.0f,%2.0f\n",c.name,c.sex,c.score[0],c.score[1]) ;}程序的运行结果是A.Qian,f,95,92B.Qian,m,85,90C.Zhao,f,95,92D.Zhao,m,85,90
有以下程序: #includestdio.h struct stu { int num; char name[10]: int age;} void fun(struct stu*p) {printf("%s\n",(*p).name);} the main { struct stu students[3]={{9801,"Zhang".20}, {9802,"Wang",19},{9803,"Zhao",1 8}} fun(students+2); } 输出的结果是( )。A. ZhangB.ZhaoC.WangD.18
以下程序的输出结果是______。includestruct stu{int num; char name[10]; int age;};v 以下程序的输出结果是______。#include<stdio.h>struct stu{ int num; char name[10]; int age;};void fun(struct stu*p){ printf("%s\n",(*p).name);}main(){ struct stu students[3]={ {9801,"Zhang",20}, { 9802,"Wang",19}, { 9803,"Zhao",18} }; fun(students+2);}A.ZhangB.ZhaoC.WangD.18
有以下程序:includeinclude struct STU {char name[10];int hum;};void f( 有以下程序:#include <stdio.h>#include <strine.h> struct STU { char name[10]; int hum;};void f(char * name,iht num){ struct STU s[2] = {{ "SunDan" ,20044} , {" Penghua" ,20045}}; num= s[0]. nnm; strepy(name,s[0], name);}main( ){ struct STU s[2] = {{"YangSan" ,20041 }, { "LiSiGao" ,20042}}, * P; p = s[1]; f(p->name,p->hum); printf("% s %d \n" ,p-> name,p->num);}程序运行后的输出结果是( )。A.SunDan 20042B.SunDan 20044C.LiSiGuo 20042D.YangSan 20041
有以下程序:includeincludetypedef struct{char name[9];char sex;float s 有以下程序: #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.namC) ; a.sex=b.sex; for(i=0;i<2;i++) a.score[i]=b.score[i]; return a; } main() {STU c={"Qian",'f',95.0,92.0},d; d=f(C) ; pintf("%s,%c,%2.of.%2.of\n",d.name,d.sex,d.score[0],score[1]); } 程序的运行结果是( )。A.Qian,f,95,92B.Qian,m,85,90C.Zhao,m,85,90D.Zhao,C95,92
单选题有以下程序#include #include 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; i2; i++) a.score[i]=b.score[i]; return a;}main(){ STU c={Qian,'f',95.0,92.0},d; d=f(c); printf(%s,%c,%2.0f,%2.0f, d.name, d.sex, d.score[0], d.score[1]);}程序的运行结果是( )。AQian,m,85,90BZhao,m,85,90CQian,f,95,92DZhao,f,95,92
单选题有以下程序:#include struct STU{ char name[9]; char sex; int score[2];};void f(struct STU a[]){ struct STU b={zhao,'m',85,90}; a[1]=b;}main(){ struct STU c[2] = {{Qian,'f',95,92}, {Qian,'f',95,92}}; f(c); printf(%s,%c,%d,%d,, c[0].name, c[0].sex, c[0].score[0], c[0].score[1]); printf(%s,%c,%d,%d, c[1].name, c[1].sex, c[1].score[0], c[1].score[1]);}程序运行后的结果是( )。AZhao,m,85,90,Sun,m,98,99BZhao,m,85,90,Qian,f,95,92CQian,f,95,92,Sun,m,98,99DQian,f,95,92,Zhao,m,85,90
单选题有以下程序:#include #include typedef struct{ char name[9]; char sex; float score[2];} STU;void 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; i2; i++) a.score[i]=b.score[i];}main(){ STU c={Qian,'f',95.0, 92.0}; f(c); printf(%s,%c,%2.0f,%2.0f, c.name, c.sex, c.score[0], c.score[1]);}程序的运行结果是( )。AQian,f,95,92BQian,m,85,90CZhao,f,95,92DZhao,m,85,90
单选题有以下函数:#include struct stu{ int num; char name[10]; int age;};void fun(struct stu *p){ printf(%s, p-name);}main(){ struct stu x[3] = {{01,Zhang,20}, {02,Wang,19}, {03,Zhao,18}}; fun(x+2);}程序运行后的输出结果是( )。AZhangBZhaoCWangD19
单选题若有以下程序#include #include #include typedef struct stu{ char *name,gender; int score;}STU;void f(char *p){ p=(char *)malloc(10); strcpy(p,Qian);}main(){ STU a={NULL,'m',290},b; a.name=(char *)malloc(10); strcpy(a.name,Zhao); b=a; f(b.name); b.gender='f'; b.score=350; printf(%s,%c,%d,, a.name, a.gender, a.score); printf(%s,%c,%d, b.name, b.gender, b.score);}则程序的输出结果是( )。AQian,m,290,Qian,f,350BZhao,m,290,Qian,f,350CQian,f,350,Qian,t,350DZhao,m,290,Zhao,f,350
单选题有以下程序:#include #include typedef struct stu{ char name[10]; char gender; int score;}STU;void f(char *name,char gender,int score){ strcpy(name,Qian); gender='f'; score=350;}main(){ STU a={Zhao,'m',290},b; b=a; f(b.name,b.gender,b.score); printf(%s,%c,%d,, a.name, a.gender, a.score); printf(%s,%c,%d, b.name, b.gender, b.score);}程序的运行结果是( )。AZhao,m,290,Qian,m,290BZhao,m,290,Zhao,m,290CZhao,m,290,Qian,m,350DZhao,m,290,Qian,f,350
单选题有以下程序:#include typedef struct stu{ char name[10]; char gender; int score; } STU;void f(STU *a, STU *b){ *b = *a; printf(%s,%c,%d,, b-name, b-gender, b-score);}main(){ STU a={Zhao, 'm', 290}, b={Qian, 'f', 350}; f(a,b); printf(%s,%c,%d, b.name, b.gender, b.score);}程序的运行结果是( )。AZhao,m,290,Zhao,m,290BZhao,in,290,Qian,f,350CQian,f,350,Qian,f,350DQian,f,350,Zhao,m,290
单选题有以下程序:#include #include typedef struct{ char name[10]; char sex; int age;}STU;void fun(STU *t){ strcpy((*t).name,Tong); (*t).age++;}main(){ STU s[2] = {Hua, 'm', 18, Qin, 'f', 19}; fun(s+1); printf(%s,%d,%s,%d, s[0].name, s[0].age, s[1].name, s[1].age);}程序运行后的输出结果是( )。AHua,18,Tong,20BHua,18,Qin,19CTong,19,Qin,19DHua,19,Tong,19
单选题有以下程序:#include typedef struct stu{ char name[10]; char gender; int score; } STU;void f(STU a, STU *b){ a = *b; printf(%s,%c,%d,, a.name, a.gender, a.score);}main(){ STU a={Zhao, 'm', 290}, b={Qian, 'f', 350}; f(a,b); printf(%s,%c,%d, a.name, a.gender, a.score);}程序运行后的输出结果是( )。AQian,f,350,Qian,f,350BZhao,m,290,Qian,f,350CQian,f,350,Zhao,m,290DZhao,m,290,Zhao,m,290
单选题有以下程序:#include #include struct S{ char name[10];};main(){ struct S s1,s2; strcpy(s1.name,XXX); strcpy(s2.name,=); s1=s2; printf(%s,s1.name);}程序运行后的输出结果是( )。A=BXXXC=XXDX=
单选题有以下程序:#include #include typedef struct stu{ char name[10]; char gender; int score;}STU;void f(STU *c){ strcpy(c-name,Qian); c-gender='f'; c-score=350;}main(){ STU a={Zhao,'m',290},b; b=a; f(b); printf(%s,%c,%d,, a.name, a.gender, a.score); printf(%s,%c,%d, b.name, b.gender, b.score);}程序运行后的输出结果是( )。AZhao,m,290,Qian,f,350BZhao,m,290,Qian,m,290CZhao,m,290,Zhao,m,290DZhao,m,290,Qian,m,350
单选题有以下程序:#include #include typedef struct{ char name[9]; char sex; float score[2];} STU;void f(STU *A){ strcpy(a-name,Zhao); a-sex='m'; a-score[1]=90.0;}main(){ STU c = {Qian,'f',95.0,92.0},*d=c; f(d); printf(%s,%c,%2.0f,%2.0f, d-name, c.sex, c.score[0], c.score[1]);}程序的运行结果是( )。AQian,f,95,92BZhao,f,95,90CZhao,m,95,90DZhao,f,95,92