学生成绩管理系统源代码c语言
时间: 2023-09-25 17:16:20 浏览: 27
以下是一个简单的学生成绩管理系统的C语言源代码,包括了添加学生信息、查询学生信息、修改学生信息和删除学生信息等功能:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student {
char name[20];
int id;
float score;
} stu[100];
int count = 0;
void add_student() {
printf("请输入学生姓名:\n");
scanf("%s", stu[count].name);
printf("请输入学生学号:\n");
scanf("%d", &stu[count].id);
printf("请输入学生分数:\n");
scanf("%f", &stu[count].score);
count++;
printf("添加成功!\n");
}
void query_student() {
int id;
printf("请输入学生学号:\n");
scanf("%d", &id);
int i;
for (i = 0; i < count; i++) {
if (stu[i].id == id) {
printf("学生姓名:%s\n", stu[i].name);
printf("学生学号:%d\n", stu[i].id);
printf("学生分数:%.2f\n", stu[i].score);
return;
}
}
printf("查无此人!\n");
}
void modify_student() {
int id;
printf("请输入学生学号:\n");
scanf("%d", &id);
int i;
for (i = 0; i < count; i++) {
if (stu[i].id == id) {
printf("请输入学生姓名:\n");
scanf("%s", stu[i].name);
printf("请输入学生学号:\n");
scanf("%d", &stu[i].id);
printf("请输入学生分数:\n");
scanf("%f", &stu[i].score);
printf("修改成功!\n");
return;
}
}
printf("查无此人!\n");
}
void delete_student() {
int id;
printf("请输入学生学号:\n");
scanf("%d", &id);
int i;
for (i = 0; i < count; i++) {
if (stu[i].id == id) {
int j;
for (j = i; j < count-1; j++) {
stu[j] = stu[j+1];
}
count--;
printf("删除成功!\n");
return;
}
}
printf("查无此人!\n");
}
void print_menu() {
printf("学生成绩管理系统\n");
printf("1. 添加学生信息\n");
printf("2. 查询学生信息\n");
printf("3. 修改学生信息\n");
printf("4. 删除学生信息\n");
printf("5. 退出系统\n");
}
int main() {
while (1) {
print_menu();
int choice;
scanf("%d", &choice);
switch (choice) {
case 1:
add_student();
break;
case 2:
query_student();
break;
case 3:
modify_student();
break;
case 4:
delete_student();
break;
case 5:
printf("谢谢使用!\n");
exit(0);
default:
printf("输入有误,请重新输入!\n");
break;
}
}
return 0;
}
```
注意:此代码仅供参考,需要根据实际需求进行修改和完善。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)