更多"有以程序#include #include typedef struc"的相关试题:
[单项选择]有以下程序
#include
#include
typedef struct {char name[9]; char sex; int score[2]; } STU;
STU f(STU a)
{ STU b={"Zhao",’m’,85,90};
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",’f’,95,92}, d;
d=f(c);
printf("%s,%c,%d,%d,",d.name, d.sex, d.score[0], d.score[1]);
printf("%s,%c,%d,%d/n",c.name, c.sex, c.score[0], c.score[1]);
}
程序运行后的输出结果是_______。
A. Zhao,m,85,90,Qian,f,95,92
B. Zhao,m,85,90, Zhao,m,85,90
C. Qian,f,95,92, Qian,f,95,92
D. Qian,f,95,92, Zhao,m,85,90
[填空题]有以下程序
#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);
}
程序运行后的输出结果是______。
[填空题]有以下程序
#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);
程序运行后的输出结果是______。
[填空题]有以下程序:
#include<stdio.h>
typedef struct
int num;double s;)REC;
void funl(REC x)x.num=23;x.s=88.5;
main( )
REC a=16,90.0);
fun1(a);
printf("%d/n",a.num);
程序运行后的输出结果是______。
[单项选择]有以下程序:
#include <stdio.h>
typedef struct { int b, p; }A;
void f(A c)/* 注意:c是结构变量名*/
{ int j;
c.b+=1; c.p+=2;
}
main( )
{ int i;
A a={1, 2};
f(a);
printf("%d, %d/n", a.b, a.P);
}
程序运行后的输出结果是______。
A. 2, 4
B. 1, 2
C. 1, 4
D. 2, 3
[单项选择]设struct
char name[10];
int age;
stu[2]="Tom",25,"Mary",26,*p=stu;
则执行语句printf("%S%d/n",P—>name,stu[1].age);后输出结果是( )
A. Tom25
B. Tom26
C. Mary25
D. Mary26
[填空题]
有以下程序
#include<stdio.h>
typedef struct
{int num;double s;}REC;
void funl(REC x){x.num=23;x.s=88.5;}
main( )
{ REC a=<16,90.0};
funl (A) ;
printf("%d/n",a.mum);
}
程序运行后的输出结果是______。
[简答题]#include<stdio.h>
typedef struct abc
{int a,b,c;
};
main( )
{struct abe s[2]={{1,2,3),{4,5,6}};
int t=-s[0].a+s[1].b;
printf("%d/n",t);
}
[单项选择]#include<stdio.h>
typedef struct abc
int a,b,c;
;
main( )
struct abe s[2]=1,2,3),4,5,6;
int t=-s[0].a+s[1].b;
printf("%d/n",t);
[单项选择]设有以下程序段:
struct MP3
char name[20];
char color;
float price;
std,*ptr;
ptr=&std;
若要引用结构体变量std中的color成员,写法错误的是( )。
A. std.color
B. ptr→color
C. std→color
D. (*ptr).color
[单项选择]有以下程序
struct STU
char name[10];
int num;
int Score;
main( )
struct Stu s[5]="YangSan",20041,703,"LiSiGuo",20042,580,
"WangYin",20043,680,"SunDan",20044,550,
"Penghua",20045;537,*p[5],*t;
int i,j;
for(i=0;i<5;i++)p[i]=&s[i];
for(i=0;i<4;i++)
for(j=i+1;j<5;j++)
if(p[i]->Score>p[j]->Score)
t=p[i];p[i]=p[j];p[i]=t;
printf("%d%d/n",s[1].Score,p[1]->Score);
执行后输出结果是
A. 550550
B. 680680
C. 580550
D. 580680
[单项选择]若有如下程序:
struct student
char name[10];
float score[3];stu[3]="lili",75,90,90,
"liudan",90,85,75;
"guoli",85,85,70;
main( )
int i;float sum=0,aver;
for(i=0;i<3;i++)
sum=sum+stu[i].score[1]; aver=sum/i;
printf("%6.2f/n",aver);
则程序运行后的输出结果是 ( )
A. 83.33
B. 85.00
C. 86.00
D. 86.67
[单项选择]有以下程序:
#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 20042
B. SunDan 20044
C. LiSiGuo 20042
D. YangSan 20041
[填空题]设struct student
char name [20];
char sex;
stu;
语句printf("%d/n",sizeof(stu));的输出结果是______。
[单项选择]有以下程序
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="SunDan",2044;
*c=b;
main( )
struct STU a="YangSan",2041,b="Wang Yin",2043;
f1(
A. ;f2(&
B. ;
[单项选择]有以下程序
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 550
(B) Penghua 20045 537
(C) LiSiGuo 20042 580
(D) SunDan 20041 703
[单项选择]有以下程序:
struct STU
char name[10];
int num;
int score;
;
main( )
struct STU s[5]="YangSan",20041,703,"LiSiGuo",20042,580,
"WangYin",20043,680,"SunDan",20044,550),
’Penghua",20045,537,*p[5],*t;
int i,j;
for(i=0;i<5;i++) p[i]=&s[i];
for(i=0;i<4;i++)
for(j=i+1;j<5;j++)
if(p[i]->Score>p[j]->Score)
t=p[i];p[i]=p[j];p[i]=t;
printf("%d %d/n",s[1].Score,p[1]->Score);
执行后输出结果是( )。
A. 550 550
B. 680 680
C. 580 550
D. 580 680