学生管理系统使用的是C语言控制台完成的
有以下功能:
======================
学生管理系统
[1] 添加学生
[2] 添加学生成绩
[3] 修改学生成绩
[4] 显示学生列表
[5] 导出学生信息到文件
[6] 从文件导入学生信息
====================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Grade {
char subject[50]; // 科目名称
float score; // 成绩
struct Grade* next; // 下一个科目节点指针
};
struct Student {
char studentID[10]; // 学号
char name[50]; // 姓名
int age; // 年龄
float gpa; // GPA
struct Grade* grades; // 科目链表头指针
struct Student* next; // 下一个学生节点指针
};
struct Student* head = NULL; // 学生链表头指针
int studentCount = 0; // 学生数量
// 检查学号是否存在
int isStudentIDExists(char* studentID) {
struct Student* current = head;
while (current != NULL) {
if (strcmp(current->studentID, studentID) == 0) {
return 1; // 学号存在
}
current = current->next;
}
return 0; // 学号不存在
}
// 自动生成学生学号
void generateStudentID(char* studentID) {
static int id = 1;
do {
sprintf(studentID, "S%04d", id);
id++;
} while (isStudentIDExists(studentID));
}
// 添加学生
void addStudent() {
struct Student* newStudent = (struct Student*)malloc(sizeof(struct Student));
generateStudentID(newStudent->studentID); // 自动生成学号
printf("自动生成的学号:%s\n", newStudent->studentID);
printf("请输入学生姓名:");
scanf("%s", newStudent->name);
printf("请输入学生年龄:");
scanf("%d", &(newStudent->age));
printf("请输入学生GPA:");
scanf("%f", &(newStudent->gpa));
newStudent->grades = NULL;
newStudent->next = NULL;
if (head == NULL) {
head = newStudent;
} else {
struct Student* current = head;
while (current->next != NULL) {
current = current->next;
}
current-&g