网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
有以下程序:#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;}程序运行后的输出结果是(  )。
A

1001,ZhangDa,1098.0

B

1002,ChangRong,1202.0

C

1001,ChangRong,1098.0

D

1002,ZhangDa,1202.0


参考答案

参考解析
解析:
当把结构体变量中的数据作为一个整体传送给相应的形参时,传递的是实参结构体变量中的值,系统将为结构体类型形参开辟相应的存储单元,并将实参中各成员的值一一对应赋给形参中的成员。函数体内对形参结构体变量中任何成员的操作,都不会影响对应实参中成员的值,从而保证了调用函数中数据的安全,但这也限制了将运算结果返回给调用函数。函数f中的结构体变量t是一个形参,在函数中对其值的改变只在函数体内有效,不影响实参。即,主函数中调用函数f以后,结构体变量a的值没有改变。答案选择A选项。
更多 “单选题有以下程序:#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;}程序运行后的输出结果是(  )。A 1001,ZhangDa,1098.0B 1002,ChangRong,1202.0C 1001,ChangRong,1098.0D 1002,ZhangDa,1202.0” 相关考题
考题 请阅读以下程序:includeincludevoid fun(int b[]){static int i=0;do{b[i] 请阅读以下程序: #include<stdio.h> #include<string.h> void fun(int b[]) { static int i=0; do {b[i]+=b[i+1]; }while(++i<2);} main() { int k,a[5]={1,3,5,4,9}; fun(A); for(k=0;k<5;k++)printf("%d",a[k]);} 上面程序的输出是( )。A.13579B.48579C.48549D.48999

考题 下列程序的运行结果是()。 include main() {stmct date {int year,month,day; }today; 下列程序的运行结果是( )。#include<stdio.h>main(){stmct date{int year,month,day;}today;primf("%d\n",sizeof(struct date));}A.8B.6C.10D.12

考题 有下列程序: include include "string.h" void tim(char *s[],int n) 有下列程序: #include <stdio.h> #include "string.h" void tim(char *s[],int n) { char *t;int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])) {t=s[i];s[i]=s[j];s[j]=t;} } main() { char *ss[]= {"bcc","bbcc","xy","aaaacc","aabcc"}; fun(ss,5);printf("%s,%s\n",ss[0],ss[4]); } 程序的运行结果是( )。A.xy,aaaaccB.aaaacc,xyC.bcc,aabccD.aabcc,bcc

考题 下列程序的运行结果为() include main() {struc tdate {int year,month,day; )today; 下列程序的运行结果为( )#include<stdio.h>main(){ struc tdate{int year,month,day;)today;printf("%d\n",sizeof(struct date));}A.8B.6C.10D.12

考题 以下程序的运行结果是#include "stdio.h"main(){struct date{int year,month,day;}today;printf("%d\n",sizeof(struct date));}A.6B.8C.10D.12

考题 以下程序的输出结果是()includemain(){struct stru{int a,b:char c[6];}:printf("%d\n 以下程序的输出结果是 ( ) #include<stdio.h> main() {struct stru{int a,b: char c[6]; }: printf("%d\n",sizeof(stru)), }A.2B.4C.8D.10

考题 有以下程序 include typedef struct { int num;double s; }REC; void funl(REC *x) { x 有以下程序 include<stdio.h> typedef struct { int num;double s; }REC; void funl(REC *x) { x->num=23;x->s=88.5; } void main() { REC a={16,90.0}; fun1(A); printf("%d\n",a.num); } 程序运行后的输出结果是( )。

考题 有以下程序:includeincludemain(){char a[]={'a','b','c','d','e','f','g' 有以下程序: #include <stdio.h> #include <string.h> main() { char a[]={'a','b','c','d','e','f','g','h','\0'}; int i,j; i=sizeof(a); j=strlen(a); printf("%d,%d\n",i,j); } 程序运行后的输出结果是( )。A.9,9B.8,9C.1,8D.9,8

考题 有以下程序: 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 struct tt { int x; struct tt *y; } *p; s 有以下程序 #include <stdio.h> struct tt { int x; struct tt *y; } *p; struct tt a[4]= {20,a+ 1,15,a+2,30,a+3,17,a}; main() { int i; p=a; for(i=1; i<-2; i++) { printf("%d,", p->x ); p=p->y; }A.20,30,B.30,17C.15,30,D.20,15,

考题 有以下程序 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 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 include main( ) {char a[ 7 ] = "a0 \0a0 \0";int i, 有以下程序:#include <stdio.h>#include <string.h>main( ) { char a[ 7 ] = "a0 \0a0 \0"; int i,j; i = sizeof(a); j = strlen(a); printf(" % d %d \n" ,i,j); }程序运行后的输出结果是( )。A.22B.76C.72D.62

考题 下列程序的输出结果是( )。 include main() { struct st { int y,x,z; }; union {long 下列程序的输出结果是( )。 #include <stdio.h> main() { struct st { int y,x,z; }; union { long i; int j; char k; } un; printf("%d,%d\n",sizeof(struct st),sizeof(un)); }A.6, 2B.6, 4C.8, 4D.8, 6

考题 有以下程序: include include struct NODE {int num;struct NODE *next; } 有以下程序:#include <stdio.h>#include <stdlib.h>struct NODE{ int num;struct NODE *next;};main(){ struet NODE *p,*q,*r;int sum=0;p=(struct NODE *) malloc(sizeof(struct NODE));q=(struct NODE *) malloc(sizeof(struet 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

考题 有以下程序:includestruct tt{int x;struct tt*y;}*p;struct tt a[4]={20,a+1,15,a+2, 有以下程序: #include<stdio.h> struct tt {int x;struct tt*y;}*p; struct tt a[4]={20,a+1,15,a+2,30,a+3,17,a} main() { int i; p=a; for(i=1;i<=2;i++){printf("%d",p->x);p=P->y;} } 程序的运行结果是( )。A.20,30,B.30,17C.15,30D.20,15

考题 有以下程序#include "stdio.h"main(){ struct date { int number; float fenzhi; char name; }stu; printf("%d\n",sizeof(stu));} 程序的运行结果是A.3 B.5C.7 D.8

考题 以下程序的输出结果是【】。 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 "stdio.h"main(){ struct date {int year,month,day;}today; printf("%d\n",sizeof(struct date));}程序的运行结果是A.6 B.8C.12 D.10

考题 有以下程序 include int fun(int a, int b) { if(b==0) return a; 有以下程序 #include <stdio.h> int fun(int a, int b) { if(b==0) return a; else return(fun(-a,-b)); } main() { printf("%d\n",fun(4,2)); } 程序的运行结果是______。A.1B.2C.3D.4

考题 有以下程序 include include int fun(int n) {int * 有以下程序 #include <stdio.h> #include <stdlib.h> int fun(int n) {int *p; p=(int*)malloc(sizeof(int)); *p=n; return *p; } { int a; a=fun(10); printf("%d\n",a+fun(10)); } 程序的运行结果是______。A.0B.10C.20D.出错

考题 有以下程序 include struct st { int x,y;} data[2]={1,10,2,20}; main( 有以下程序 #include <stdio.h> struct st { int x,y;} data[2]={1,10,2,20}; main() { struct st *p=data; printf("%d,",p->y); printf("%d\n",(++p)->x); } 程序的运行结果是______。A.10,1B.20,1C.10,2D.20,2

考题 有以下程序:include include main(int argc,char *argv[]){ int i,len=0;f 有以下程序: #include <stdio.h> #include <string.h> main(int argc,char *argv[]) { int i,len=0; for(i=1;i<argc;i+=2)len+=strlen(argv[i]); prinff("%d\n",len); } 此程序经编译链接后生成的可执行文件是ex.exe,若运行时输入以下带参数的命令行: ex abed efg h3 k44则执行后的输出结果时( )。A.14B.12C.8D.6

考题 下列程序的运行结果为()。includemain(){struct date {int year,month,day; }today; pr 下列程序的运行结果为( )。 #include<stdio.h> main() { struct date {int year,month,day; }today; printf("%d\n",sizeof(struct date)); }A.8B.6C.10D.12

考题 以下程序的输出结果是() includemain(){ union un{int i; long k; char c;};struct by 以下程序的输出结果是( ) # include<stdio.h> main() { union un{int i; long k; char c; }; struct byte{ int a; long b; union un c; } r; printf("%d\n",sizeof(r)); }A.10B.13C.7D.8

考题 有以下程序: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 include main(){char *p[10]={"abc","aabdfg","dcdbe" 有以下程序: #include <stdio.h> #include <string.h> main() { char *p[10]={"abc","aabdfg","dcdbe","abbd","cd"}; printf("%d\n",strlen(p[4])); } 执行后的输出结果是( )。A.2B.3C.4D.5

考题 在下列# include命令中,正确的一条是 ( )A.# include [string.h]B.# include {math.h}C.# include(stdio.h)D.# include<stdio.h>