|
|
|
@ -0,0 +1,889 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
|
|
// 定义成绩结构体
|
|
|
|
|
typedef struct Score
|
|
|
|
|
{
|
|
|
|
|
char name[50];
|
|
|
|
|
float score;
|
|
|
|
|
} Score;
|
|
|
|
|
|
|
|
|
|
// 定义学生结构体
|
|
|
|
|
typedef struct Student
|
|
|
|
|
{
|
|
|
|
|
char name[50];
|
|
|
|
|
int id;
|
|
|
|
|
float key;
|
|
|
|
|
Score performance[3];
|
|
|
|
|
} Student;
|
|
|
|
|
|
|
|
|
|
// 定义老师结构体
|
|
|
|
|
typedef struct Teacher
|
|
|
|
|
{
|
|
|
|
|
char name[50];
|
|
|
|
|
int id;
|
|
|
|
|
float key;
|
|
|
|
|
} Teacher;
|
|
|
|
|
|
|
|
|
|
// 定义管理员
|
|
|
|
|
typedef struct SystemManager
|
|
|
|
|
{
|
|
|
|
|
char key[10];
|
|
|
|
|
} SystemManager;
|
|
|
|
|
|
|
|
|
|
// 定义函数
|
|
|
|
|
|
|
|
|
|
// 老师端
|
|
|
|
|
void teacherMenu(Student students[], int numStudent, Teacher teacher);
|
|
|
|
|
void addStudent(Student students[], int *numStudent);
|
|
|
|
|
int searchStudent1(Student students[], int numStudent);
|
|
|
|
|
void searchStudent2(Student students[], int numStudent);
|
|
|
|
|
void deleteStudent(Student students[], int *numStudent);
|
|
|
|
|
void modifyStudent(Student students[], int numStudent);
|
|
|
|
|
void printAllStudent(Student students[], int numStudent);
|
|
|
|
|
void changeTearcherPassword(Teacher teacher);
|
|
|
|
|
int teacherLogin(Teacher teachers[], int *numTeacher);
|
|
|
|
|
|
|
|
|
|
// 学生端
|
|
|
|
|
void studentMenu(Student student, int numStudent);
|
|
|
|
|
void printScore(Student student, int numStudent);
|
|
|
|
|
void changeStudentPassword(Student student);
|
|
|
|
|
int studentLogin(Student students[], int *numStudent);
|
|
|
|
|
|
|
|
|
|
// 管理员端
|
|
|
|
|
void managerMenu(Student students[], int numStudent, Teacher teachers[], int numTeacher);
|
|
|
|
|
|
|
|
|
|
void printAllStudent(Student students[], int numStudent);
|
|
|
|
|
void addStudent(Student students[], int *numStudent);
|
|
|
|
|
void searchStudent2(Student students[], int numStudent);
|
|
|
|
|
void deleteStudent(Student students[], int *numStudent);
|
|
|
|
|
void modifyStudent(Student students[], int numStudent);
|
|
|
|
|
void changePassword1(Student students[], int numStudent);
|
|
|
|
|
|
|
|
|
|
void printAllTeacher(Teacher teachers[], int numTeacher);
|
|
|
|
|
void addTeacher(Teacher teachers[], int *numTeacher);
|
|
|
|
|
void searchTeacher(Teacher teachers[], int numTeacher);
|
|
|
|
|
void deleteTeacher(Teacher teachers[], int *numTeacher);
|
|
|
|
|
void modifyTeacher(Teacher teachers[], int numTeacher);
|
|
|
|
|
void changePassword2(Teacher teachers[], int numTeacher);
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
SetConsoleOutputCP(65001);
|
|
|
|
|
// 初始化管理员信息
|
|
|
|
|
struct SystemManager manager;
|
|
|
|
|
strcpy(manager.key, "123.com");
|
|
|
|
|
|
|
|
|
|
struct Student students[500]; // 存储学生信息
|
|
|
|
|
int numStudent = 2; // 学生总人数
|
|
|
|
|
|
|
|
|
|
struct Teacher teachers[100]; // 存储教师信息
|
|
|
|
|
int numTeacher = 1; // 教师总人数
|
|
|
|
|
|
|
|
|
|
// 基础信息
|
|
|
|
|
strcpy(students[0].name, "张三");
|
|
|
|
|
students[0].key = 123456;
|
|
|
|
|
students[0].id = 20221001;
|
|
|
|
|
strcpy(students[0].performance[0].name, "语文");
|
|
|
|
|
strcpy(students[0].performance[1].name, "数学");
|
|
|
|
|
strcpy(students[0].performance[2].name, "英语");
|
|
|
|
|
students[0].performance[0].score = 95;
|
|
|
|
|
students[0].performance[1].score = 100;
|
|
|
|
|
students[0].performance[2].score = 120;
|
|
|
|
|
|
|
|
|
|
strcpy(students[1].name, "李四");
|
|
|
|
|
students[1].key = 123456;
|
|
|
|
|
students[1].id = 20221002;
|
|
|
|
|
strcpy(students[1].performance[0].name, "语文");
|
|
|
|
|
strcpy(students[1].performance[1].name, "数学");
|
|
|
|
|
strcpy(students[1].performance[2].name, "英语");
|
|
|
|
|
students[1].performance[0].score = 115;
|
|
|
|
|
students[1].performance[1].score = 110;
|
|
|
|
|
students[1].performance[2].score = 130;
|
|
|
|
|
|
|
|
|
|
strcpy(teachers[0].name, "王五");
|
|
|
|
|
teachers[0].key = 123456;
|
|
|
|
|
teachers[0].id = 19781001;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
printf("\n\n*************欢迎使用学生管理系统*************\n");
|
|
|
|
|
printf("* 1.学生登陆 *\n");
|
|
|
|
|
printf("* 2.教师登陆 *\n");
|
|
|
|
|
printf("* 3.管理员登陆 *\n");
|
|
|
|
|
printf("* 0.退出 *\n");
|
|
|
|
|
printf("***********************************************\n");
|
|
|
|
|
|
|
|
|
|
int choice;
|
|
|
|
|
scanf("%d", &choice);
|
|
|
|
|
|
|
|
|
|
if (choice == 1)
|
|
|
|
|
{ // 学生
|
|
|
|
|
int num;
|
|
|
|
|
num = studentLogin(students, &numStudent);
|
|
|
|
|
if (num != 1000)
|
|
|
|
|
{
|
|
|
|
|
studentMenu(students[num], numStudent);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("登陆失败,返回主界面\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 2)
|
|
|
|
|
{ // 教师
|
|
|
|
|
int num;
|
|
|
|
|
num = teacherLogin(teachers, &numTeacher);
|
|
|
|
|
if (num != 1000)
|
|
|
|
|
{
|
|
|
|
|
teacherMenu(students, numStudent, teachers[num]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("登陆失败,返回主界面\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 3)
|
|
|
|
|
{ // 管理员
|
|
|
|
|
int cmp;
|
|
|
|
|
char input[8];
|
|
|
|
|
printf("\n请输入密码:");
|
|
|
|
|
scanf("%s", input);
|
|
|
|
|
cmp = strcmp(manager.key, input);
|
|
|
|
|
if (cmp == 0)
|
|
|
|
|
{
|
|
|
|
|
managerMenu(students, numStudent, teachers, numTeacher);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("登陆失败。\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 0)
|
|
|
|
|
{ // 退出
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("非法输入,请重新输入\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 学生端
|
|
|
|
|
|
|
|
|
|
// 登陆
|
|
|
|
|
int studentLogin(Student students[], int *numStudent)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请输入学生的id:");
|
|
|
|
|
int id;
|
|
|
|
|
float key;
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
|
|
|
|
|
int i, n;
|
|
|
|
|
n = 0;
|
|
|
|
|
for (i = 0; i < *numStudent; i++)
|
|
|
|
|
{
|
|
|
|
|
if (students[i].id == id)
|
|
|
|
|
{
|
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (n != 0)
|
|
|
|
|
{
|
|
|
|
|
printf("请输入密码:");
|
|
|
|
|
scanf("%f", &key);
|
|
|
|
|
if (key == students[i].key)
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("密码错误\n");
|
|
|
|
|
return 1000;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("id错误");
|
|
|
|
|
return 1000;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打印菜单
|
|
|
|
|
void studentMenu(Student student, int numStudent)
|
|
|
|
|
{
|
|
|
|
|
int choice;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
printf("\t%s同学\tID:%d\n你好!\n", student.name, student.id);
|
|
|
|
|
printf("**************欢迎使用学生管理系统*************\n");
|
|
|
|
|
printf("* 1.查看成绩 *\n");
|
|
|
|
|
printf("* 2.修改密码 *\n");
|
|
|
|
|
printf("* 0.退出 *\n");
|
|
|
|
|
printf("***********************************************\n");
|
|
|
|
|
printf("请输入您的选择:");
|
|
|
|
|
scanf("%d", &choice);
|
|
|
|
|
|
|
|
|
|
if (choice == 1)
|
|
|
|
|
{ // 查看成绩
|
|
|
|
|
printScore(student, numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 2)
|
|
|
|
|
{ // 修改密码
|
|
|
|
|
changeStudentPassword(student);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 0)
|
|
|
|
|
{ // 退出
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("非法输入,请重新输入\n");
|
|
|
|
|
}
|
|
|
|
|
} while (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查看成绩
|
|
|
|
|
void printScore(Student student, int numStudent)
|
|
|
|
|
{
|
|
|
|
|
printf("\n\n%s同学,你的成绩如下:\n", student.name);
|
|
|
|
|
printf("%s: %.2f\n", student.performance[0].name, student.performance[0].score);
|
|
|
|
|
printf("%s: %.2f\n", student.performance[1].name, student.performance[0].score);
|
|
|
|
|
printf("%s: %.2f\n", student.performance[2].name, student.performance[0].score);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改密码
|
|
|
|
|
void changeStudentPassword(Student student)
|
|
|
|
|
{
|
|
|
|
|
float key1, key2;
|
|
|
|
|
printf("请输入旧密码:");
|
|
|
|
|
scanf("%f", &key1);
|
|
|
|
|
if (key1 == student.key)
|
|
|
|
|
{
|
|
|
|
|
printf("密码正确,请输入新密码:");
|
|
|
|
|
scanf("%f", &key2);
|
|
|
|
|
student.key = key2;
|
|
|
|
|
printf("修改成功!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("密码错误");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 教师端
|
|
|
|
|
|
|
|
|
|
// 打印菜单
|
|
|
|
|
void teacherMenu(Student students[], int numStudent, Teacher teacher)
|
|
|
|
|
{
|
|
|
|
|
int choice;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
printf("\t%s老师\tID:%d\n您好!\n", teacher.name, teacher.id);
|
|
|
|
|
printf("*************欢迎使用学生管理系统*************\n");
|
|
|
|
|
printf("* 1.添加学生 *\n");
|
|
|
|
|
printf("* 2.查找学生 *\n");
|
|
|
|
|
printf("* 3.删除学生 *\n");
|
|
|
|
|
printf("* 4.修改学生信息 *\n");
|
|
|
|
|
printf("* 5.输出所有学生信息 *\n");
|
|
|
|
|
printf("* 6.修改密码 *\n");
|
|
|
|
|
printf("* 0.退出 *\n");
|
|
|
|
|
printf("***********************************************\n");
|
|
|
|
|
printf("请输入您的选择:");
|
|
|
|
|
scanf("%d", &choice);
|
|
|
|
|
|
|
|
|
|
if (choice == 1)
|
|
|
|
|
{ // 添加学生
|
|
|
|
|
addStudent(students, &numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 2)
|
|
|
|
|
{ // 查找学生
|
|
|
|
|
searchStudent2(students, numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 3)
|
|
|
|
|
{ // 删除学生
|
|
|
|
|
deleteStudent(students, &numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 4)
|
|
|
|
|
{ // 修改学生信息
|
|
|
|
|
modifyStudent(students, numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 5)
|
|
|
|
|
{ // 输出所有学生信息
|
|
|
|
|
printAllStudent(students, numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 6)
|
|
|
|
|
{ // 修改密码
|
|
|
|
|
changeTearcherPassword(teacher);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 0)
|
|
|
|
|
{ // 退出
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("非法输入,请重新输入\n");
|
|
|
|
|
}
|
|
|
|
|
} while (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 教师登陆
|
|
|
|
|
int teacherLogin(Teacher teachers[], int *numTeacher)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请输入教师的id:");
|
|
|
|
|
int id;
|
|
|
|
|
float key;
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
|
|
|
|
|
int i, n;
|
|
|
|
|
n = 0;
|
|
|
|
|
for (i = 0; i < *numTeacher; i++)
|
|
|
|
|
{
|
|
|
|
|
if (teachers[i].id == id)
|
|
|
|
|
{
|
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (n != 0)
|
|
|
|
|
{
|
|
|
|
|
printf("请输入教师的密码:");
|
|
|
|
|
scanf("%f", &key);
|
|
|
|
|
if (key == teachers[i].key)
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("密码错误\n");
|
|
|
|
|
return 1000;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("id错误");
|
|
|
|
|
return 1000;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加学生
|
|
|
|
|
void addStudent(Student students[], int *numStudent)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请输入学生姓名:");
|
|
|
|
|
scanf("%s", students[*numStudent].name);
|
|
|
|
|
|
|
|
|
|
printf("请输入学生学号:");
|
|
|
|
|
scanf("%d", &students[*numStudent].id);
|
|
|
|
|
|
|
|
|
|
printf("请输入学生分数:\n");
|
|
|
|
|
Score s1 = students[*numStudent].performance[0];
|
|
|
|
|
Score s2 = students[*numStudent].performance[1];
|
|
|
|
|
Score s3 = students[*numStudent].performance[2];
|
|
|
|
|
strcpy(s1.name, "语文");
|
|
|
|
|
strcpy(s1.name, "数学");
|
|
|
|
|
strcpy(s1.name, "英语");
|
|
|
|
|
printf("语文:");
|
|
|
|
|
scanf("%f", &s1.score);
|
|
|
|
|
printf("数学:");
|
|
|
|
|
scanf("%f", &s2.score);
|
|
|
|
|
printf("英语:");
|
|
|
|
|
scanf("%f", &s3.score);
|
|
|
|
|
|
|
|
|
|
printf("默认密码:123456\n");
|
|
|
|
|
students[*numStudent].key = 123456;
|
|
|
|
|
|
|
|
|
|
printf("添加成功\n");
|
|
|
|
|
(*numStudent)++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查找学生1
|
|
|
|
|
int searchStudent1(Student students[], int numStudent)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请选择搜索需要修改学生的方式:\n1.姓名\n2.学号\n");
|
|
|
|
|
int choice;
|
|
|
|
|
scanf("%d", &choice);
|
|
|
|
|
int i, n;
|
|
|
|
|
n = 0;
|
|
|
|
|
if (choice == 1)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请输入要查找的学生姓名:");
|
|
|
|
|
char name[50];
|
|
|
|
|
scanf("%s", name);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numStudent; i++)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(students[i].name, name) == 0)
|
|
|
|
|
{
|
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 2)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请输入学生的学号:");
|
|
|
|
|
int id;
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < numStudent; i++)
|
|
|
|
|
{
|
|
|
|
|
if (students[i].id == id)
|
|
|
|
|
{
|
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("输入格式错误!");
|
|
|
|
|
}
|
|
|
|
|
if (n == 0)
|
|
|
|
|
{
|
|
|
|
|
return 1000;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 查找学生2
|
|
|
|
|
void searchStudent2(Student students[], int numStudent)
|
|
|
|
|
{
|
|
|
|
|
int i = searchStudent1(students, numStudent);
|
|
|
|
|
if (i != 1000)
|
|
|
|
|
{
|
|
|
|
|
printf("姓名:%s \n学号:%d \n分数:\n", students[i].name, students[i].id);
|
|
|
|
|
printf("%s: %.2f\n", students[i].performance[0].name, students[i].performance[0].score);
|
|
|
|
|
printf("%s: %.2f\n", students[i].performance[1].name, students[i].performance[1].score);
|
|
|
|
|
printf("%s: %.2f\n", students[i].performance[2].name, students[i].performance[2].score);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("查无此人!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 删除学生
|
|
|
|
|
void deleteStudent(Student students[], int *numStudent)
|
|
|
|
|
{
|
|
|
|
|
printf("请输入要删除的学生的学号:");
|
|
|
|
|
int id;
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < *numStudent; i++)
|
|
|
|
|
{
|
|
|
|
|
if (students[i].id == id)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i < *numStudent)
|
|
|
|
|
{
|
|
|
|
|
for (int j = i; j < (*numStudent) - 1; j++)
|
|
|
|
|
{
|
|
|
|
|
students[j] = students[j + 1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(*numStudent)--;
|
|
|
|
|
printf("删除成功\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("查无此人\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改学生信息
|
|
|
|
|
void modifyStudent(Student students[], int numStudent)
|
|
|
|
|
{
|
|
|
|
|
int i = searchStudent1(students, numStudent);
|
|
|
|
|
if (i != 1000)
|
|
|
|
|
{
|
|
|
|
|
int choice;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n*******************修改学生信息******************\n");
|
|
|
|
|
printf("* 1.修改学生姓名 *\n");
|
|
|
|
|
printf("* 2.修改学生语文成绩 *\n");
|
|
|
|
|
printf("* 3.修改学生数学成绩 *\n");
|
|
|
|
|
printf("* 4.修改学生英语成绩 *\n");
|
|
|
|
|
printf("* 0.退出 *\n");
|
|
|
|
|
printf("***********************************************\n");
|
|
|
|
|
printf("请输入您的选择:");
|
|
|
|
|
scanf("%d", &choice);
|
|
|
|
|
float x;
|
|
|
|
|
char y[50];
|
|
|
|
|
switch (choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
printf("将名字修改为:");
|
|
|
|
|
scanf("%s", &y);
|
|
|
|
|
strcpy(students[i].name, y);
|
|
|
|
|
printf("修改完成!");
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
printf("将%s的原成绩为%f", students[i].performance[0].name, students[i].performance[0].score);
|
|
|
|
|
printf("修改为:");
|
|
|
|
|
scanf("%f", &x);
|
|
|
|
|
students[i].performance[0].score = x;
|
|
|
|
|
printf("修改完成!");
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
printf("将%s的原成绩为%f", students[i].performance[1].name, students[i].performance[1].score);
|
|
|
|
|
printf("修改为:");
|
|
|
|
|
scanf("%f", &x);
|
|
|
|
|
students[i].performance[0].score = x;
|
|
|
|
|
printf("修改完成!");
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
printf("将%s的原成绩为%f", students[i].performance[2].name, students[i].performance[2].score);
|
|
|
|
|
printf("修改为:");
|
|
|
|
|
scanf("%f", &x);
|
|
|
|
|
students[i].performance[0].score = x;
|
|
|
|
|
printf("修改完成!");
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("输入错误!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} while (choice != 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("查无此人!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改密码
|
|
|
|
|
void changeTearcherPassword(Teacher teacher)
|
|
|
|
|
{
|
|
|
|
|
float key1, key2;
|
|
|
|
|
printf("\n请输入旧密码:");
|
|
|
|
|
scanf("%f", &key1);
|
|
|
|
|
if (key1 == teacher.key)
|
|
|
|
|
{
|
|
|
|
|
printf("密码正确,请输入新密码:");
|
|
|
|
|
scanf("%f", &key2);
|
|
|
|
|
teacher.key = key2;
|
|
|
|
|
printf("修改成功!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("密码错误");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查看所有学生
|
|
|
|
|
void printAllStudent(Student students[], int numStudent)
|
|
|
|
|
{
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf(" 姓名 | ID\n");
|
|
|
|
|
printf("-------------------------------\n");
|
|
|
|
|
for (int i = 0; i < numStudent; i++)
|
|
|
|
|
{
|
|
|
|
|
printf("%s\t\t%d\n", students[i].name, students[i].id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 管理员端
|
|
|
|
|
// 面板
|
|
|
|
|
void managerMenu(Student students[], int numStudent, Teacher teachers[], int numTeacher)
|
|
|
|
|
{
|
|
|
|
|
int choice;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
int choice;
|
|
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
printf("***************欢迎使用学生管理系统*************\n");
|
|
|
|
|
printf("* 1.管理学生 *\n");
|
|
|
|
|
printf("* 2.管理教师 *\n");
|
|
|
|
|
printf("* 0.退出 *\n");
|
|
|
|
|
printf("***********************************************\n");
|
|
|
|
|
printf("请输入您的选择:");
|
|
|
|
|
scanf("%d", &choice);
|
|
|
|
|
|
|
|
|
|
if (choice == 1)
|
|
|
|
|
{ // 学生
|
|
|
|
|
int x;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
printf("***************欢迎使用学生管理系统*************\n");
|
|
|
|
|
printf("* 1.添加学生 *\n");
|
|
|
|
|
printf("* 2.查找学生 *\n");
|
|
|
|
|
printf("* 3.删除学生 *\n");
|
|
|
|
|
printf("* 4.修改学生信息 *\n");
|
|
|
|
|
printf("* 5.输出所有学生信息 *\n");
|
|
|
|
|
printf("* 6.修改密码 *\n");
|
|
|
|
|
printf("* 0.返回上一界面 *\n");
|
|
|
|
|
printf("***********************************************\n");
|
|
|
|
|
printf("请输入您的选择:");
|
|
|
|
|
scanf("%d", &x);
|
|
|
|
|
if (x == 1)
|
|
|
|
|
{ // 添加学生
|
|
|
|
|
addStudent(students, &numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (x == 2)
|
|
|
|
|
{ // 查找学生
|
|
|
|
|
searchStudent2(students, numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (x == 3)
|
|
|
|
|
{ // 删除学生
|
|
|
|
|
deleteStudent(students, &numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (x == 4)
|
|
|
|
|
{ // 修改学生信息
|
|
|
|
|
modifyStudent(students, numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (x == 5)
|
|
|
|
|
{ // 输出所有学生信息
|
|
|
|
|
printAllStudent(students, numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (x == 6)
|
|
|
|
|
{ // 修改密码
|
|
|
|
|
changePassword1(students, numStudent);
|
|
|
|
|
}
|
|
|
|
|
else if (x == 0)
|
|
|
|
|
{ // 退出
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("非法输入,请重新输入\n");
|
|
|
|
|
}
|
|
|
|
|
} while (1);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 2)
|
|
|
|
|
{ // 教师
|
|
|
|
|
int y;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
printf("***************欢迎使用学生管理系统*************\n");
|
|
|
|
|
printf("* 1.添加教师 *\n");
|
|
|
|
|
printf("* 2.查找教师 *\n");
|
|
|
|
|
printf("* 3.删除教师 *\n");
|
|
|
|
|
printf("* 4.修改教师姓名 *\n");
|
|
|
|
|
printf("* 5.输出所有教师信息 *\n");
|
|
|
|
|
printf("* 6.修改密码 *\n");
|
|
|
|
|
printf("* 0.返回上一界面 *\n");
|
|
|
|
|
printf("***********************************************\n");
|
|
|
|
|
printf("请输入您的选择:");
|
|
|
|
|
scanf("%d", &y);
|
|
|
|
|
if (y == 1)
|
|
|
|
|
{ // 添加教师
|
|
|
|
|
addTeacher(teachers, &numTeacher);
|
|
|
|
|
}
|
|
|
|
|
else if (y == 2)
|
|
|
|
|
{ // 查找教师
|
|
|
|
|
searchTeacher(teachers, numTeacher);
|
|
|
|
|
}
|
|
|
|
|
else if (y == 3)
|
|
|
|
|
{ // 删除教师
|
|
|
|
|
deleteTeacher(teachers, &numTeacher);
|
|
|
|
|
}
|
|
|
|
|
else if (y == 4)
|
|
|
|
|
{ // 修改教师信息
|
|
|
|
|
modifyTeacher(teachers, numTeacher);
|
|
|
|
|
}
|
|
|
|
|
else if (y == 5)
|
|
|
|
|
{ // 输出所有教师信息
|
|
|
|
|
printAllTeacher(teachers, numTeacher);
|
|
|
|
|
}
|
|
|
|
|
else if (y == 6)
|
|
|
|
|
{ // 修改密码
|
|
|
|
|
changePassword2(teachers, numTeacher);
|
|
|
|
|
}
|
|
|
|
|
else if (y == 0)
|
|
|
|
|
{ // 退出
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("非法输入,请重新输入\n");
|
|
|
|
|
}
|
|
|
|
|
} while (1);
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 0)
|
|
|
|
|
{ // 退出
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("非法输入,请重新输入\n");
|
|
|
|
|
}
|
|
|
|
|
} while (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查看所有教师
|
|
|
|
|
void printAllTeacher(Teacher teachers[], int numTeacher)
|
|
|
|
|
{
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf(" 姓名 | ID\n");
|
|
|
|
|
printf("-------------------------------\n");
|
|
|
|
|
for (int i = 0; i < numTeacher; i++)
|
|
|
|
|
{
|
|
|
|
|
printf("%s\t\t%d\n", teachers[i].name, teachers[i].id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加教师
|
|
|
|
|
void addTeacher(Teacher teachers[], int *numTeacher)
|
|
|
|
|
{
|
|
|
|
|
printf("请输入教师姓名:");
|
|
|
|
|
scanf("%s", teachers[*numTeacher].name);
|
|
|
|
|
|
|
|
|
|
printf("请输入教师ID:");
|
|
|
|
|
scanf("%d", &teachers[*numTeacher].id);
|
|
|
|
|
|
|
|
|
|
printf("默认密码:123456\n");
|
|
|
|
|
teachers[*numTeacher].key = 123456;
|
|
|
|
|
|
|
|
|
|
printf("添加成功\n");
|
|
|
|
|
(*numTeacher)++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查教师生1
|
|
|
|
|
int searchTeacher1(Teacher teachers[], int numTeacher)
|
|
|
|
|
{
|
|
|
|
|
printf("请选择搜索需要修改教师的方式:\n1.姓名\n2.ID\n");
|
|
|
|
|
int choice;
|
|
|
|
|
scanf("%d", &choice);
|
|
|
|
|
int i, n;
|
|
|
|
|
n = 0;
|
|
|
|
|
if (choice == 1)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请输入要查找的教师姓名:");
|
|
|
|
|
char name[50];
|
|
|
|
|
scanf("%s", name);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numTeacher; i++)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(teachers[i].name, name) == 0)
|
|
|
|
|
{
|
|
|
|
|
n++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (choice == 2)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请输入要修改信息教师的ID:");
|
|
|
|
|
int id;
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < numTeacher; i++)
|
|
|
|
|
{
|
|
|
|
|
if (teachers[i].id == id)
|
|
|
|
|
{
|
|
|
|
|
n++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("输入格式错误!");
|
|
|
|
|
}
|
|
|
|
|
if (n == 0)
|
|
|
|
|
{
|
|
|
|
|
return 1000;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 查找教师2
|
|
|
|
|
void searchTeacher(Teacher teachers[], int numTeacher)
|
|
|
|
|
{
|
|
|
|
|
int i = searchTeacher1(teachers, numTeacher);
|
|
|
|
|
if (i != 1000)
|
|
|
|
|
{
|
|
|
|
|
printf("姓名:%s \nID:%d ", teachers[i].name, teachers[i].id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("查无此人!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 删除教师
|
|
|
|
|
void deleteTeacher(Teacher teachers[], int *numTeacher)
|
|
|
|
|
{
|
|
|
|
|
printf("请输入要删除的教师的学号:");
|
|
|
|
|
int id;
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < *numTeacher; i++)
|
|
|
|
|
{
|
|
|
|
|
if (teachers[i].id == id)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i < *numTeacher)
|
|
|
|
|
{
|
|
|
|
|
for (int j = i; j < (*numTeacher) - 1; j++)
|
|
|
|
|
{
|
|
|
|
|
teachers[j] = teachers[j + 1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(*numTeacher)--;
|
|
|
|
|
printf("删除成功\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("查无此人\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改教师信息
|
|
|
|
|
void modifyTeacher(Teacher teachers[], int numTeacher)
|
|
|
|
|
{
|
|
|
|
|
int i = searchTeacher1(teachers, numTeacher);
|
|
|
|
|
char y[50];
|
|
|
|
|
printf("修改为:");
|
|
|
|
|
scanf("%s", &y);
|
|
|
|
|
strcpy(teachers[i].name, y);
|
|
|
|
|
printf("修改完成!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改教师密码
|
|
|
|
|
void changePassword2(Teacher teachers[], int numTeacher)
|
|
|
|
|
{
|
|
|
|
|
int i = searchTeacher1(teachers, numTeacher);
|
|
|
|
|
float key;
|
|
|
|
|
printf("旧密码:%f\n", teachers[i].key);
|
|
|
|
|
printf("请输入新密码:");
|
|
|
|
|
scanf("%f", &key);
|
|
|
|
|
teachers[i].key = key;
|
|
|
|
|
printf("修改成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改学生密码
|
|
|
|
|
void changePassword1(Student students[], int numStudent)
|
|
|
|
|
{
|
|
|
|
|
int i = searchStudent1(students, numStudent);
|
|
|
|
|
float key;
|
|
|
|
|
printf("旧密码:%f\n", students[i].key);
|
|
|
|
|
printf("请输入新密码:");
|
|
|
|
|
scanf("%f", &key);
|
|
|
|
|
students[i].key = key;
|
|
|
|
|
printf("修改成功!");
|
|
|
|
|
}
|