单选题有以下程序:#include #include struct A{ int a; char b[10]; double c;};struct A f(struct A t);main(){ struct A a={1001,ZhangDa,1098.0}; a=f(a); printf(%d,%s,%6.1f,a.a,a.b,a.c);}struct A f(struct A t){ t.a=1002; strcpy(t.b,ChangRong); t.c=1202.0; return t;}程序运行后的输出结果是( )。A1001,ZhangDa,1098.0B1002,ZhangDa,1202.0C1001,ChangRong,1098.0D1002,ChangRong,1202.0
单选题
有以下程序:#include #include struct A{ int a; char b[10]; double c;};struct A f(struct A t);main(){ struct A a={1001,ZhangDa,1098.0}; a=f(a); printf(%d,%s,%6.1f,a.a,a.b,a.c);}struct A f(struct A t){ t.a=1002; strcpy(t.b,ChangRong); t.c=1202.0; return t;}程序运行后的输出结果是( )。
A
1001,ZhangDa,1098.0
B
1002,ZhangDa,1202.0
C
1001,ChangRong,1098.0
D
1002,ChangRong,1202.0
参考解析
解析:
函数f对结构体成员进行修改,并返回新的结构体;main函数先定义了一个结构体变量a并为它赋初值,然后调用函数f修改结构体变量的成员值,最后输出新的结构体变量成员值。答案选择D选项。
函数f对结构体成员进行修改,并返回新的结构体;main函数先定义了一个结构体变量a并为它赋初值,然后调用函数f修改结构体变量的成员值,最后输出新的结构体变量成员值。答案选择D选项。
相关考题:
下列程序的运行结果为【14】#include stdio.h#include string.hstruct A{int a;char b[10];double c;};void f (struct A *t);main(){struct A a=(1001,”ZhangDa”,1098,0);f(a);printf(“d,s,6,if\n”,a.a,a.b,a.c);}void f(struct A *t){strcpy(t-b,”ChangRong”); }
下列程序的运行结果为【 1 4 】#include stdio.h#include string.hstruct A{int a; char b[10];double c;};void f(struct A *t);main(){ struct A a={1001,"ZhangDa",1098.0};f(a); printf("%d,%s,%6.1f\n",a.a,a.b,a.c);}void f(struct A *t){ strcpy(t-b,"ChangRong");}
有以下程序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
下列程序的输出结果是()。includestruct abc{int a, b, c, s;};main(){struct abc s[2] 下列程序的输出结果是( )。 #include <stdio.h> struct abc { int a, b, c, s;}; main() { struct abc s[2]={{1,2,3},{4,5,6}}; int t; t=s[0].a+s[1].b; printf("%d\n",t); }A.5B.6C.7D.8
有以下程序 struc t STU{ char name [10] int num; void f1(struct STU c) { struct STU b={"LiSiGuo",2042}; c=b; } void f2(struct STU *c) { struct STU b={"SunDan",2044); *c=b; } main ( ) { struct STU a={"YangSan",2041},b={"WangYin",2043}; f1 (a); f2 (b); printf ( "%d %d\n" ,a.num,b.num); } 执行后输出结果是A.2041 2044B.2041 2043C.2042 2044D.2042 2043
有以下程序#inculde stdio.h#inculde string.hstrtict A{ int a;char B[10];douBle c;};void F (struct A t);main(){ struct A a ={1001,”zhangDa”,1098.0};F(a);printF(“%d,%s,%6.1F\n”,a.,a.B,a.c);void F(struct A t){ t.a=1002;strcpy(t.B,”ChangRong”);t.c=1202.0;}程序运行后的输出结果是A.1001,zhangDa,1098.0B.1002,ChangRong,1202.0C.1001,ChangRong,10980D.1002,zhangDa,1202.0
有以下程序: include struct STU {int num; float TotalScore; 有以下程序: #include <strino.h> struct STU {int num; float TotalScore; }; void f(struct STU p) {struct STU s[2]={{20044,550},{20045,537}}; p.num=s[1].num;p.TotalScore=s[1].TotalScore; } main() {struct STU s[2]={{20041,703},{20042,580}}; f(s[0]); printf("%d%3.0t\n",s[0].num,s[0].TotalScore); } 程序运行后的输出结果是 ______。A.20045 537B.20044 550C.20042 580D.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 {int a; char b[10]; double c;}; 下列程序的运行结果为【 】。include<stdio.h>include<string.h>{ int a; char b[10]; double c; };void f (struct A *t);main(){ struct A a={1001,"ZhangDa",1098.0};f(a) ; printf("%d,%s,%6.lf\n",a.a,a.b,a.C);}void f(struct A*t){ strcpy(t->b, "ChangRong");}
以下程序的输出结果是【】。 include main() {struct stru {int a; float b; char d[4]; } 以下程序的输出结果是【 】。include<stdio.h>main(){ struct stru{ int a;float b;char d[4];};printf("%d\n",sizeof(struct stru));}
有以下程序 include struct NODE {int num;stmct NODE*next;}; main() { struct NODE 有以下程序#include<stdlib.h>struct NODE{ int num;stmct NODE*next;};main(){ struct NODE*p,*q,*r;p=(struct NODE*)malloc(sizeof(struct NODE));q=(struct NODE*)malloc(sizeof(struct NODE));r=(struct NODE*)malloc(sizeof(struct NODE));p->num=10;q->num=20;r->num=30;p->next=q;q->next=r;printf(“%d\n”,p->num+q->next->num);}程序运行后的输出结果是A.10B.20C.30D.40
有以下程序 include struct NODE{ int num; struct NODE *next;}; main( ) 有以下程序#include <stdlib.h>struct NODE{int num;struct NODE *next;};main( ){ struct NODE *p,*q,*r;int sum=0;p=(struct NODE *)malloc(sizeof(struct NODE));q=(struct NODE *)malloc(sizeof(struct NODE));r=(struct NODE *)malloc(sizeof(struct NODE));p->num=1;q->num=2;r->num=3;p->next=q;q->next=r;r->next=NULL;sum+=q->next->num;sum+=p->num;printf(“%d\n”,sum);}执行后的输出结果是A.3B.4C.5D.6
有以下程序#includestdio.h#includestring.hstruet A{int a;char b[10];double c;};struct A f(struct A t);main( ){struct A a={1001,“ZhangDa”,1098.0);a=f(A);prinff(“%d,%S,%6.1f\n”,a.a,a.b,a.e);}struct A f(struct A t){t.a=1002;strepy(t.b,“changRong”);t.c=1202.O;return t;}程序运行后的输出结果是A.1001,ZhangDa,1098.0B.1002,ZhangDa,1202.0C.1001,ChangRong,1098.0D.1002,ChangRong,1202.0
有以下程序: #includestdi0.h #includestring.h struct A {int a;char b[10];double C;); void f(struct A t); main( ) {struct A a={"1001,"ZhangDa",l098,0}; f(a);printf("%d,%S,%6.1f\n",a.a,a.b,a.c);} void f(struct A t) {t.a=1002;strcpy(t.b,"ChangRon9");t.c=1202.0;} 程序运行后的输出结果是( )。A.1001,ZhangDa,1098.0B.1002,ChangRong,1202.0C.1001,ChangRong,1098.0D.1002,ZhangDa,1202.0
有以下程序: include struct NODE { int num; struct NODE*next; }; main() { struct 有以下程序:#include <stdlib.h>struct NODE{ int num; struct NODE *next; };main(){ struct NODE *p,*q,*r;p=(struct NODE*)malloc(sizeof(struct NODE));q=(struct NODE*)mallloc(sizeof(struct NODE));r=(struct NODE*)malloc(sizeof(struct NODE));p->num=10;q->num=20; r->num=30;p->next=q;q->next=r;printf("%d\n",p->num+q->next->num);}程序运行后的输出结果是( )。A.10B.20C.30D.40
有以下程序: #includestdio.h #includestring.h struct A {int a;char b[10];double C;); struct A f(struct A t): main( ) {struct A a={1001,"ZhangDa",l098.0}; a=f(a);printf("%d,%S,%6.1f\n",a.a,a.b,a.c); } struct A f(struct A t) {t.a= 1002;strcpy(t.b,"ChangRon9");t.c=1202.0;return t;} 程序运行后的输出结果是( )。A.1001,ZhangDa,1098.0B.1002,ZhangDa,1202.0C.1001,ChangRong,1098.0D.1002,ChangRong,1202.0
有以下程序:struct S{int n;int a[20];};void f(struct S*P){int i,j,t;for(i=0;in-1;i++)fo 有以下程序: struct S{int n;int a[20];}; void f(struct S*P) { int i,j,t; for(i=0;i<P->n-1;i++) for(j=j+1;j<P->n-1;j++) if(p->a[i]>p->a[j]) {t=P->a[i];p->a[i]=P->a[j];p->a[j]=t} } main() {int i;struct S s{10,{2,3,1,6,8,7,5,4,10,9}}; f(&s); for(i=0;i<s.n;i++)printf("%d",s.a[i]);} 程序运行后的输出结果是( )。A.3B.4C.5D.6
有以下程序 include gtruet NODE {intnum;struct NODE *next;}; main() {struct NODE 有以下程序#include <stdlib.h>gtruet NODE{ int num; struct NODE *next; };main(){struct NODE *p,*q,*r;p=(struct NODE*)malloc(sizeof (struct NODE));q=(struct NODE*)malloc(sizeof (struct NODE));r=(struct NODE*)malloc(sizeef (struct NODE));p->num=10; q->num=20; r->num=30;p->next=q; q->next-r;printf("%d\n",p->num+q->next->num);}程序运行后的输出结果是A.10B.20C.30D.50
有以下程序: include struct NODE {int num;stmct NODE *next;}; main( ) { str 有以下程序:#include<stdlib.h>struct NODE{ int num;stmct NODE *next;};main( ){ struct NODE * p, * q,* r;p=(struct NODE * )malloc(sizeof(struct NODE) );q=(struct NODE * )malloc(sizeof(struct NODE) );r=(struct NODE * )malloc(sizeof(struct NODE) );p->num=10; q->num=20; r->num=30;p->next=q; q->next=r;printf("%d\n",p->num+q->next->num);}程序运行后的输出结果是A.10B.20C.30D.40
有以下程序:include struct STU{char name[10]; int num;};void f1(struct STU c){ st 有以下程序: #include <stdio.h> struct STU { char name[10]; int num; }; void f1(struct STU c) { struct STU b={"LiSiGuo",2042}; c=b; } void f2(struct STU *c) { struct STU b={"SanDan",2044}; *c=b; } main() { struct STU a={"YangSan",2041}, b={"WangYin",2043}; f1(a); f2(b); printf("%d%d\n",a.num,b.hum); } 执行后的输出结果是( )。A.2041 2044B.2041 2043C.2042 2044D.2042 2043
有以下程序 include struct NODE {int num;struct NODE*next;} main() {struct NODE 有以下程序#include<stdlib.h>struct NODE{int num;struct NODE*next;}main(){struct NODE *P,*q,*r;p=(struct NODE *)malloc(sizeof(struct NODE));q=(struct NODE *)malloc(sizeof(struet NODE));r=(struct NODE*)malloc(sizeof(struct NODE)):p->num=10;q->num=20;r->num=30;p->next=q;q->next=r;printf("%d\n",p->num+q->next->num):}程序运行后的输出结果是( )A.10B.20C.30D.40
有以下程序: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
( 37 )有以下程序#include stdio.h#include string.hstruct A{ int a; char b[10]; double c;};void f ( struct A t ) ;main (){ struct A a={1001, " ZhangDa " ,1098.0};f ( a ) ; printf ( " %d,%s,%6.1f\n " ,a.a,a.b,a.c ) ;}void f ( struct A t ){ t.a=1002; strcpy ( t.b, " ChangRong " ) ;t.c=1202.0;}程序运行后的输出结果是A ) 1001,zhangDa,1098.0B ) 1002,changRong,1202.0C ) 1001,ehangRong,1098.OD ) 1002,ZhangDa,1202.0
单选题有如下程序:#include #include struct S{ char name[10];};void change(struct S *data,int value){ strcpy(data-name, ****); value=13;}main(){ struct S input; int num = 4; strcpy(input.name, THIS); change(input,num); printf(%s,%d,input.name,num);}程序运行后的输出结果是( )。A****,4B****,13CTHIS,4DTHIS,13
单选题有以下程序#include #include struct S{ char name[10];};void change(struct S *data, int value){ strcpy(data-name, #); value = 6;}main(){ struct S input; int num = 3; strcpy(input.name, OK); change(input, num); printf(%s,%d, input.name, num);}程序运行后的输出结果是( )。AOK,6B#,6COK,3D#,3
单选题有以下程序:#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 struct A{ int a; char b[10]; double c;};void f(struct A t);main(){ struct A a={1001,ZhangDa,1098.0}; f(a); printf(%d,%s,%6.1f,a.a,a.b,a.c);}void f(struct A t){ t.a=1002; strcpy(t.b,ChangRong); t.c=1202.0; return t;}程序运行后的输出结果是( )。A1001,ZhangDa,1098.0B1002,ChangRong,1202.0C1001,ChangRong,1098.0D1002,ZhangDa,1202.0