用C语言表示:假设百分制课程成绩和4分制绩点对应计算方法如下: 90-100 4.0 ; 85-89 3.7 ; 82-84 3.3 ; 78-81 3.0 ; 75-77 2.7 ; 72-74 2.3 ; 68-71 2.0 ; 64-67 1.5 ; 60-63 1.0 ; 60分以下0 学分加权平均绩点为:[(学分1* 绩点1)+(学分2* 绩点2)...]/(学分1+学分2...) 输入若干个学生学号(4位数字)和若干门课的百分制成绩和对应学分,按照学生的学分加权平均绩点倒序输出学号和加权平均绩点。以*为结束 输入格式: 学号 百分制成绩 学分 每行一个,以-1为结束记号。 输出格式: 按平均绩点从高到低输出: 学号 平均绩点,每行一个,绩点保留2位小数。
时间: 2024-04-01 09:34:34 浏览: 124
学生成绩平均绩点的计算(c语言)
好的,以下是一个基本的实现,你可以根据需要进行修改:
```c
#include <stdio.h>
int main() {
int num, score, credit, total_credit = 0;
float point, total_point = 0.0;
printf("请输入学号、成绩和学分,每行一个,以-1为结束记号:\n");
scanf("%d", &num);
while (num != -1) {
scanf("%d%d", &score, &credit);
if (score >= 90 && score <= 100) {
point = 4.0;
} else if (score >= 85 && score <= 89) {
point = 3.7;
} else if (score >= 82 && score <= 84) {
point = 3.3;
} else if (score >= 78 && score <= 81) {
point = 3.0;
} else if (score >= 75 && score <= 77) {
point = 2.7;
} else if (score >= 72 && score <= 74) {
point = 2.3;
} else if (score >= 68 && score <= 71) {
point = 2.0;
} else if (score >= 64 && score <= 67) {
point = 1.5;
} else if (score >= 60 && score <= 63) {
point = 1.0;
} else {
point = 0.0;
}
total_credit += credit;
total_point += point * credit;
scanf("%d", &num);
}
printf("按平均绩点从高到低输出:\n");
printf("学号 平均绩点\n");
while (total_credit > 0) {
printf("%d %.2f\n", num, total_point / total_credit);
total_credit = 0;
total_point = 0.0;
scanf("%d", &num);
while (num != -1) {
scanf("%d%d", &score, &credit);
if (score >= 90 && score <= 100) {
point = 4.0;
} else if (score >= 85 && score <= 89) {
point = 3.7;
} else if (score >= 82 && score <= 84) {
point = 3.3;
} else if (score >= 78 && score <= 81) {
point = 3.0;
} else if (score >= 75 && score <= 77) {
point = 2.7;
} else if (score >= 72 && score <= 74) {
point = 2.3;
} else if (score >= 68 && score <= 71) {
point = 2.0;
} else if (score >= 64 && score <= 67) {
point = 1.5;
} else if (score >= 60 && score <= 63) {
point = 1.0;
} else {
point = 0.0;
}
total_credit += credit;
total_point += point * credit;
scanf("%d", &num);
}
}
printf("*\n");
return 0;
}
```
阅读全文