学生成绩管理系统学生成绩管理系统c语言
时间: 2024-01-06 22:25:50 浏览: 49
学生成绩管理系统是一个用于记录和管理学生成绩的系统。下面是两个C语言实现学生成绩管理系统的例子:
1. 使用结构体数组实现学生成绩管理系统:
```c
#include <stdio.h>
#include <string.h>
struct student {
int num;
char name[20];
float pingshi;
float shiyan;
float kaoshi;
float total;
};
int main() {
struct student stu[100];
int count = 0;
char end[] = "end";
printf("请输入学生信息(输入end结束):\n");
while (1) {
printf("学号:");
scanf("%d", &stu[count].num);
if (strcmp(stu[count].num, end) == 0) {
break;
}
printf("姓名:");
scanf("%s", stu[count].name);
printf("平时成绩:");
scanf("%f", &stu[count].pingshi);
printf("实验成绩:");
scanf("%f", &stu[count].shiyan); printf("考试成绩:");
scanf("%f", &stu[count].kaoshi);
stu[count].total = stu[count].pingshi + stu[count].shiyan + stu[count].kaoshi;
count++;
}
printf("\n学生成绩如下:\n");
printf("学号\t姓名\t平时成绩\t实验成绩\t考试成绩\t总成绩\n");
for (int i = 0; i < count; i++) {
printf("%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n", stu[i].num, stu[i].name, stu[i].pingshi, stu[i].shiyan, stu[i].kaoshi, stu[i].total);
}
return 0;
}
```
2. 使用函数实现学生成绩管理系统:
```c
#include <stdio.h>
#include <string.h>
struct student {
int num;
char name[20]; float pingshi;
float shiyan;
float kaoshi;
float total;
};
void input(struct student *stu) {
printf("学号:");
scanf("%d", &stu->num);
printf("姓名:");
scanf("%s", stu->name);
printf("平时成绩:");
scanf("%f", &stu->pingshi);
printf("实验成绩:");
scanf("%f", &stu->shiyan);
printf("考试成绩:");
scanf("%f", &stu->kaoshi);
stu->total = stu->pingshi + stu->shiyan + stu->kaoshi;
}
void output(struct student *stu) {
printf("%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n", stu->num, stu->name, stu->pingshi, stu->shiyan, stu->kaoshi, stu->total);
}
int main() {
struct student stu[100];
int count = 0;
char end[] = "end";
printf("请输入学生信息(输入end结束):\n");
while (1) {
input(&stu[count]);
if (strcmp(stu[count].name, end) == 0) {
break;
}
count++;
}
printf("\n学生成绩如下:\n");
printf("学号\t姓名\t平时成绩\t实验成绩\t考试成绩\t总成绩\n");
for (int i = 0; i < count; i++) {
output(&stu[i]);
}
return 0;
}
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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://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://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)