填空题
程序通过定义并赋初值的方式,利用结构体变量存储了一名学生的信息。函数show的功能是输出这位学生的信息。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
typedef struct
{int num;
char name[9];
char sex;
struct(int year,month,day;}birthday;
float score[3];
}STU;
/**********found**********/
void show(STU
1)
{int i;
print["/n%d %s % c% d-%d-%d",tt.num,tt.name,tt.sex,tt.birthday year,tt.birthday.month,tt.birthday.day);
for(i=0; i<3; i++)
/**********found**********/
print[("%5.1f",
2);
printf("/n");
}
main()
{STU std={1,"Zhanghua","M",1961,10,8,76.5,78.0,82.0};
printf("/nA student data:/n");
/**********found**********/
show(
3);
}
【正确答案】
【答案解析】(1)tt (2)tt.score[i] (3)std
[解析] 填空1:形参函数定义时,参数类型标示符指明了参数类型,在printf("/n%d %s %c %d-%d-%d", tt.num, tt.name, tt.sex, tt.birthday.year, tt.birthday.month, tt.birthday.day)函数中所用到的tt没有定义,因而想到此处应填写tt。
填空2:show函数是输出学生的信息,因而此处应该用tt.score[i]来表明学生的成绩输出。
填空3:根据show函数的形参的定义可知,此处应填写std。