2. 编写一个程序,输入下列学生成绩表中的数据,并用结构体数组存放。然后统计并输出三门课程的名称和平均分数。 Name Zhao Qian Sun Foxbase 97.5 90.0 75.0 Basic 89.0 93.0 79.0 C 78.0 87.5 68.5 提示:结构体可以定义如下: struct student {
char name[10]; float foxbase; float basic; float c; }
参考答案: 一、单项选择题
1.A 2.A 3.C 4.C 5.B 6.D 7.B 8.C 9.B 10.D 11.B 12.A 13.D 14.A 15.B 16.C 17.D 18.D 19.D 20.C 二、填空题
1. return void 2. 1 0 3. #define 常量名 常量值 4. 方法和步骤 5. ‘a’、‘b’、‘\\0’ 6. 8140 7. 99
8. a[1] 30
9. fopen() fclose() fseek()
10. ASCII文件(或文本文件) 二进制文件 三、程序分析题 1. 8,10 2. 852
3. i=0,sum=30 4. 12 5. abcDEF
四、程序填充题 1. &x x<=1.0 %d 2. s=0; %d 3. k;
strlen(str)-1 str[j]=k; 4. j++
(x%j==0) y==1
5. fopen(“mytest.dat”,”r”) ch=fgetc(fp); !feof(fp) 五、程序设计题
1. #include
main() { int x;
printf(“input x:”); scanf(“%d”,&x);
if (x==0) printf(“zero”);
else if (x%2==0) printf(“even”); else printf(“odd”); }
2. #include
char name[10]; float foxbase; float basic; float c; }
main()
{ struct student stu[3]={{\
{\
int i;
printf(\ for(i=0;i<3;i++)
printf(\
(stu[i].foxbase+stu[i].basic+stu[i].c)/3);
}