学生成绩管理系统课程设计
时间: 2023-12-22 09:28:38 浏览: 94
学生成绩管理系统是一种常见的课程设计,其主要功能是对学生的基本信息和成绩信息进行管理。下面是该系统的主要功能和实现方法:
1. 学生信息管理
可以通过文件的方式存储学生的基本信息,包括学号、姓名、性别、年龄等。可以实现增加、删除、修改和查询学生信息的功能。
2. 学生成绩管理
可以通过文件的方式存储学生成绩信息,包括学号、姓名、课程名称、成绩等。可以实现增加、删除、修改和查询学生成绩的功能。同时,可以按照学生或课程进行成绩的统计和排名。
3. 查询功能
可以实现按照学号、姓名、课程名称等条件进行查询,同时可以按照成绩进行排序和排名。
4. 不及格学生查询
可以实现查询有两门及以上不及格课程的学生信息和成绩。
下面是一个简单的C语言实现示例:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_STUDENT_NUM 100
#define MAX_COURSE_NUM 5
typedef struct {
char id[20];
char name[20];
char sex[10];
int age;
} Student;
typedef struct {
char name[20];
float score[MAX_STUDENT_NUM];
} Course;
typedef struct {
Student student[MAX_STUDENT_NUM];
Course course[MAX_COURSE_NUM];
float score[MAX_STUDENT_NUM][MAX_COURSE_NUM];
int student_num;
int course_num;
} ScoreManagementSystem;
void init(ScoreManagementSystem *sms) {
sms->student_num = 0;
sms->course_num = 0;
memset(sms->score, 0, sizeof(sms->score));
}
void add_student(ScoreManagementSystem *sms, Student student) {
if (sms->student_num >= MAX_STUDENT_NUM) {
printf("The number of students has reached the maximum!\n");
return;
}
sms->student[sms->student_num++] = student;
}
void delete_student(ScoreManagementSystem *sms, char *id) {
int i, j;
for (i = 0; i < sms->student_num; i++) {
if (strcmp(sms->student[i].id, id) == 0) {
for (j = i; j < sms->student_num - 1; j++) {
sms->student[j] = sms->student[j + 1];
}
sms->student_num--;
break;
}
}
}
void modify_student(ScoreManagementSystem *sms, char *id, Student student) {
int i;
for (i = 0; i < sms->student_num; i++) {
if (strcmp(sms->student[i].id, id) == 0) {
sms->student[i] = student;
break;
}
}
}
void query_student(ScoreManagementSystem *sms, char *id) {
int i;
for (i = 0; i < sms->student_num; i++) {
if (strcmp(sms->student[i].id, id) == 0) {
printf("id: %s, name: %s, sex: %s, age: %d\n", sms->student[i].id, sms->student[i].name, sms->student[i].sex, sms->student[i].age);
break;
}
}
}
void add_course(ScoreManagementSystem *sms, Course course) {
if (sms->course_num >= MAX_COURSE_NUM) {
printf("The number of courses has reached the maximum!\n");
return;
}
sms->course[sms->course_num++] = course;
}
void delete_course(ScoreManagementSystem *sms, char *name) {
int i, j;
for (i = 0; i < sms->course_num; i++) {
if (strcmp(sms->course[i].name, name) == 0) {
for (j = i; j < sms->course_num - 1; j++) {
sms->course[j] = sms->course[j + 1];
}
sms->course_num--;
break;
}
}
}
void modify_course(ScoreManagementSystem *sms, char *name, Course course) {
int i;
for (i = 0; i < sms->course_num; i++) {
if (strcmp(sms->course[i].name, name) == 0) {
sms->course[i] = course;
break;
}
}
}
void query_course(ScoreManagementSystem *sms, char *name) {
int i;
for (i = 0; i < sms->course_num; i++) {
if (strcmp(sms->course[i].name, name) == 0) {
printf("name: %s\n", sms->course[i].name);
int j;
for (j = 0; j < sms->student_num; j++) {
printf("id: %s, name: %s, score: %f\n", sms->student[j].id, sms->student[j].name, sms->score[j][i]);
}
break;
}
}
}
void add_score(ScoreManagementSystem *sms, char *id, char *name, float score) {
int i, j;
for (i = 0; i < sms->student_num; i++) {
if (strcmp(sms->student[i].id, id) == 0) {
for (j = 0; j < sms->course_num; j++) {
if (strcmp(sms->course[j].name, name) == 0) {
sms->score[i][j] = score;
break;
}
}
break;
}
}
}
void delete_score(ScoreManagementSystem *sms, char *id, char *name) {
int i, j;
for (i = 0; i < sms->student_num; i++) {
if (strcmp(sms->student[i].id, id) == 0) {
for (j = 0; j < sms->course_num; j++) {
if (strcmp(sms->course[j].name, name) == 0) {
sms->score[i][j] = 0;
break;
}
}
break;
}
}
}
void modify_score(ScoreManagementSystem *sms, char *id, char *name, float score) {
int i, j;
for (i = 0; i < sms->student_num; i++) {
if (strcmp(sms->student[i].id, id) == 0) {
for (j = 0; j < sms->course_num; j++) {
if (strcmp(sms->course[j].name, name) == 0) {
sms->score[i][j] = score;
break;
}
}
break;
}
}
}
void query_score(ScoreManagementSystem *sms, char *id, char *name) {
int i, j;
for (i = 0; i < sms->student_num; i++) {
if (strcmp(sms->student[i].id, id) == 0) {
for (j = 0; j < sms->course_num; j++) {
if (strcmp(sms->course[j].name, name) == 0) {
printf("id: %s, name: %s, score: %f\n", sms->student[i].id, sms->student[i].name, sms->score[i][j]);
break;
}
}
break;
}
}
}
void average_score_by_student(ScoreManagementSystem *sms, char *id) {
int i, j;
float sum = 0;
int count = 0;
for (i = 0; i < sms->student_num; i++) {
if (strcmp(sms->student[i].id, id) == 0) {
for (j = 0; j < sms->course_num; j++) {
sum += sms->score[i][j];
count++;
}
break;
}
}
printf("average score of student %s is %f\n", id, sum / count);
}
void average_score_by_course(ScoreManagementSystem *sms, char *name) {
int i, j;
float sum = 0;
int count = 0;
for (i = 0; i < sms->course_num; i++) {
if (strcmp(sms->course[i].name, name) == 0) {
for (j = 0; j < sms->student_num; j++) {
sum += sms->score[j][i];
count++;
}
break;
}
}
printf("average score of course %s is %f\n", name, sum / count);
}
void query_failed_student(ScoreManagementSystem *sms) {
int i, j;
for (i = 0; i < sms->student_num; i++) {
int count = 0;
for (j = 0; j < sms->course_num; j++) {
if (sms->score[i][j] < 60) {
count++;
}
}
if (count >= 2) {
printf("id: %s, name: %s\n", sms->student[i].id, sms->student[i].name);
for (j = 0; j < sms->course_num; j++) {
printf("%s: %f\n", sms->course[j].name, sms->score[i][j]);
}
}
}
}
int main() {
ScoreManagementSystem sms;
init(&sms);
Student student1 = {"001", "Tom", "male", 18};
Student student2 = {"002", "Jerry", "male", 19};
add_student(&sms, student1);
add_student(&sms, student2);
Course course1 = {"Math", {0}};
Course course2 = {"English", {0}};
add_course(&sms, course1);
add_course(&sms, course2);
add_score(&sms, "001", "Math", 80);
add_score(&sms, "001", "English", 90);
add_score(&sms, "002", "Math", 70);
add_score(&sms, "002", "English", 60);
query_student(&sms, "001");
query_course(&sms, "Math");
query_score(&sms, "001", "Math");
average_score_by_student(&sms, "001");
average_score_by_course(&sms, "Math");
query_failed_student(&sms);
return 0;
}
```
阅读全文