高校学科竞赛管理系统C语言代码实现教师功能,教师有审核学生信息功能和显示所有竞赛信息功能
时间: 2024-02-19 10:58:32 浏览: 101
以下是一个简单的高校学科竞赛管理系统的C语言代码实现,包括了教师的审核学生信息和显示所有竞赛信息功能:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_STUDENT_NUM 100
#define MAX_NAME_LENGTH 20
#define MAX_ID_LENGTH 10
#define MAX_COMPETITION_NUM 20
#define MAX_COMP_NAME_LENGTH 50
// 学生结构体
struct Student {
char name[MAX_NAME_LENGTH];
char id[MAX_ID_LENGTH];
char competition[MAX_COMP_NAME_LENGTH];
int status; // 审核状态:0-未审核,1-已通过,2-未通过
};
// 竞赛结构体
struct Competition {
char name[MAX_COMP_NAME_LENGTH];
char introduction[100];
int year;
int month;
int day;
};
// 学生数组和竞赛数组
struct Student students[MAX_STUDENT_NUM];
struct Competition competitions[MAX_COMPETITION_NUM];
int num_students = 0;
int num_competitions = 0;
// 添加学生
void add_student() {
if (num_students >= MAX_STUDENT_NUM) {
printf("学生人数已满,无法添加新学生。\n");
return;
}
printf("请输入学生姓名:");
scanf("%s", students[num_students].name);
printf("请输入学生学号:");
scanf("%s", students[num_students].id);
printf("请输入学生报名竞赛名称:");
scanf("%s", students[num_students].competition);
students[num_students].status = 0; // 初始状态为未审核
num_students++;
printf("添加成功!\n");
}
// 显示所有学生
void show_students() {
printf("姓名\t学号\t审核状态\t报名竞赛\n");
for (int i = 0; i < num_students; i++) {
printf("%s\t%s\t", students[i].name, students[i].id);
if (students[i].status == 0) {
printf("未审核\t");
} else if (students[i].status == 1) {
printf("已通过\t");
} else {
printf("未通过\t");
}
printf("%s\n", students[i].competition);
}
}
// 审核学生
void audit_student() {
char name[MAX_NAME_LENGTH];
char id[MAX_ID_LENGTH];
printf("请输入要审核的学生姓名:");
scanf("%s", name);
printf("请输入要审核的学生学号:");
scanf("%s", id);
for (int i = 0; i < num_students; i++) {
if (strcmp(students[i].name, name) == 0 && strcmp(students[i].id, id) == 0) {
int status;
printf("请输入审核状态(1-通过,2-未通过):");
scanf("%d", &status);
students[i].status = status;
printf("审核成功!\n");
return;
}
}
printf("未找到该学生,请检查姓名和学号是否正确。\n");
}
// 添加竞赛
void add_competition() {
if (num_competitions >= MAX_COMPETITION_NUM) {
printf("竞赛数量已满,无法添加新竞赛。\n");
return;
}
printf("请输入竞赛名称:");
scanf("%s", competitions[num_competitions].name);
printf("请输入竞赛介绍:");
scanf("%s", competitions[num_competitions].introduction);
printf("请输入竞赛举办时间(格式:年 月 日):");
scanf("%d %d %d", &competitions[num_competitions].year, &competitions[num_competitions].month, &competitions[num_competitions].day);
num_competitions++;
printf("添加成功!\n");
}
// 显示所有竞赛
void show_competitions() {
printf("竞赛名称\t竞赛介绍\t举办时间\n");
for (int i = 0; i < num_competitions; i++) {
printf("%s\t%s\t%d年%d月%d日\n", competitions[i].name, competitions[i].introduction, competitions[i].year, competitions[i].month, competitions[i].day);
}
}
// 主函数
int main() {
int choice;
while (1) {
printf("\n");
printf("1. 添加学生\n");
printf("2. 显示所有学生\n");
printf("3. 审核学生\n");
printf("4. 添加竞赛\n");
printf("5. 显示所有竞赛\n");
printf("6. 退出\n");
printf("请选择您要执行的操作:");
scanf("%d", &choice);
switch (choice) {
case 1:
add_student();
break;
case 2:
show_students();
break;
case 3:
audit_student();
break;
case 4:
add_competition();
break;
case 5:
show_competitions();
break;
case 6:
return 0;
default:
printf("无效的选择,请重新输入。\n");
}
}
return 0;
}
```
以上代码只是一个简单的示例,实际开发中还需要对输入进行校验、使用文件存储数据等等。
阅读全文