#include <stdio.h>
#include <stdlib.h>
//#include <windows.h>
int main() {
int n;
printf("请输入总学生人数:");
scanf("%d", &n);
//int students[n], score1[n], score2[n], score3[n],
char students[n][100]; int score1[n], score2[n], score3[n],
sum[n]; //学生编号 语文 数学 英语 总成绩
int pass_c = 0, pass_m = 0, pass_e = 0; //各科的合格人数
float sum_c = 0, sum_m = 0, sum_e = 0, avgsum = 0; //各科总成绩及其总成绩
for (int i = 0; i < n; i++) {
printf("请输入学生的编号:");
//scanf("%d", &students[i]);
scanf("%s", students[i]);
printf("请输入学生三科的成绩(输入格式如121 121 121):");
scanf("%d%d%d", &score1[i], &score2[i], &score3[i]);
// system("cls");
system("clear");
sum[i] = score1[i] + score2[i] + score3[i];
sum_c += score1[i];
sum_m += score2[i];
sum_e += score3[i];
avgsum += sum[i];
if (score1[i] > 90) {
pass_c++;
}
if (score2[i] > 90) {
pass_m++;
}
if (score3[i] > 90) {
pass_e++;
}
}
//打印成绩单
printf(" **成绩单**\n");
printf("编号\t语文\t数学\t英语\t总分\n");
for (int a = 0; a < n; a++) {
//printf("%d\t%d\t%d\t%d\t%d\n", students[a], score1[a], score2[a], score3[a],
printf("%s\t%d\t%d\t%d\t%d\n", students[a], score1[a], score2[a], score3[a],
sum[a]);
}
printf("在此次的考试中语文的及格率为%.2f,数学的及格率为%.2f,英语的及格率为%."
"2f\n",
(float)pass_c / n, (float)pass_m / n, (float)pass_e / n);
printf("本次考试语文的平均成绩为%.2f\n数学的平均成绩为%.2f\n英语的平均成绩为%"
//".2f\n总成绩的平均成绩为%.2f",
".2f\n总成绩的平均成绩为%.2f\n",
(float)sum_c / n, (float)sum_m / n, (float)sum_e / n,
(float)avgsum / n);
return 0;
}
|