用c语言代码写出:输入n(scanf)个学生,分别输入每个学生的学号 姓名 语文成绩 数学成绩 英语成绩, 将成绩表输出,成绩表包括每个学生的 学号 姓名 语文成绩 数学成绩 英语成绩 总分
时间: 2023-09-07 15:11:07 浏览: 62
好的,这是一个很基础的C语言编程问题,下面是相应的代码:
```c
#include <stdio.h>
struct Student {
int id;
char name[20];
int chinese;
int math;
int english;
int total;
};
int main() {
int n;
printf("请输入学生人数:\n");
scanf("%d", &n);
struct Student students[n];
printf("请依次输入每个学生的学号、姓名、语文成绩、数学成绩和英语成绩:\n");
for (int i = 0; i < n; i++) {
scanf("%d %s %d %d %d", &students[i].id, students[i].name, &students[i].chinese, &students[i].math, &students[i].english);
students[i].total = students[i].chinese + students[i].math + students[i].english;
}
printf("学号\t姓名\t语文成绩\t数学成绩\t英语成绩\t总分\n");
for (int i = 0; i < n; i++) {
printf("%d\t%s\t%d\t%d\t%d\t%d\n", students[i].id, students[i].name, students[i].chinese, students[i].math, students[i].english, students[i].total);
}
return 0;
}
```
当您输入学生数量n和每个学生的详细信息后,程序将按照您的输入打印出成绩表,其中包括每个学生的学号、姓名、语文成绩、数学成绩、英语成绩和总分。如果您还有其他问题,请继续提出。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![xlsx](https://img-home.csdnimg.cn/images/20210720083732.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)