大学第一个设计,代码量3700+行,本课设仅供参考
1 【课程设计】教务信息管理系统
Time Limit:1000MS Memory Limit:65535K
题型: 人工评判题 语言: 无限制
描述
设计一个教务信息管理系统,该程序具有以下功能:
(1)录入如下信息:
学生基本信息:如学号、姓名、性别、年龄、宿舍号码、电话号码等。
课程基本信息:课程编号、课程名称、考试成绩、平时成绩、综合成绩、学分、重修否等。
如果重修,需要考虑重修学期、重修成绩,并且要考虑多次重修的情况。
(2)录入选课信息
(3)录入学生成绩
(3)按班统计学生选课情况及考试成绩。
(4)按课程统计学生名单及考试成绩。
(5)统计并输出每个同学已修学分及不及级课程。
(6)实现单词组合查询课程名,例如输入“JAVA+设计”查询,可以查到如下课程
《JAVA语言与程序设计》
《JAVA程序设计》
《JAVA语言与算法设计》
注:因为上面课程名中均包含“设计”和“教程”两个单词
同理,输入“JAVA+算法+设计”查询,则只能查到《JAVA语言与算法设计》
任务要求:
(1)按照分析、设计、编码、调试和测试过程完成应用程序;
(2)学习并使用流程图等工具,并在撰写报告中使用;
(3)程序的各项功能在程序运行时,以菜单方式选择并执行;
(4)要求用户输入数据时,要给出清晰、明确的提示,包括:输入数据的内容、格式及结束方式等
(5)所有的信息存储在文件中,并实现文件读写操作。
(6)记录添加删除操作时,先从文件载入数据,用链表存放,批量操作完后,数据从链表写入文件。
(7)【加分选做】根据学生的选课,能够生成一个学生的课表(形式与我校教务处系统中的课表相似),并将时间有冲突的课程标记为红色
输入格式
提示
(1)学生基本信息可以设计一个结构体类型
(2)自己构思并增加的除规定功能之外的新功能,酌情加分。
结构体及函数声明
#define _CRT_SECURE_NO_WARNINGS
#include Stdio.h>
#include iostream>
#include string>
using namespace std;
#includemalloc.h>
#pragma once
#define InitStudentNum 1000
typedef struct Grade {
//学生学号
int StudentNum;
//学生是否选课 1为选 0为不选
int Judge = 0;
//重修 0为不用重修 1为重修
int Retake=0;
//平时成绩
double OrdinaryGrade=0;
//考试成绩
double TestGrade=0;
//总成绩
double TotalGrade=0;
};
//单个课程结构
typedef struct Course {
//课程编号
int SubNum;
//课程名字
char SubName[20];
//任课老师
string Teacher;
//任课地点
string Position;
//任课时间
string Time;
//评价
char Evaluation[10][200] = {'0'};
//课程学分
int SubCredits = 0;
int Capacity = 0;
struct Grade Grade[InitStudentNum];
struct Course* next;
}Course,*LinkCourse;
//学生个人信息结构体(完成)
typedef struct PersonalInformation {
//学生学号
int StudentNum;
//学生姓名
string StudentName;
//学生性别
string StudentSex;
//学生年龄
string StudentAge;
//学生宿舍号码
string StudentDorm;
//学生电话号码
string StudentPhone;
};
//学生结构
typedef struct Student {
struct PersonalInformation PersonalInformation;
//学生学分
int StudentCredits = 0;
//下一个学生
struct Student* next;
}Student, * LinkStudent;
//学生账号
typedef struct UserStudent {
int StudentNum;
string Account;
string Password;
struct UserStudent* next;
}UserStudent,*LinkUserStudent;
//教师账号
typedef struct UserTeacher {
string Account;
string Password;
struct UserTeacher* next;
}UserTeacher,*LinkUserTeacher;
//管理员账号
typedef struct UserAdministrator {
string Account;
string Password;
struct UserAdministrator* next;
}UserAdministrator,*LinkUserAdministrator;
//通过学号找到学生函数
LinkStudent SearchStudent(int StudentNum, LinkStudent StudentHead);
//复制课程链表
LinkCourse copyCourse(LinkCourse CourseHead);
//通过name字符关键词筛选CopyHead中符合条件的节点
LinkCourse NameCourse(LinkCourse CopyHead, char name[]);
//通过课程编号查找课程
LinkCourse SearchCourseID(int SubNum, LinkCourse CourseHead);
//课程关键字搜索得到复制的课程指针
LinkCourse SearchCourse_byword(LinkCourse CourseHead);
//通过关键词或编号得到课程
LinkCourse GetCourse(LinkCourse CourseHead);
//录入管理员账号
LinkUserAdministrator EntryAdministrator(LinkUserAdministrator AdministratorHead);
//录入教师账号
LinkUserTeacher EntryTeacher(LinkUserTeacher UserTeacherHead);
//录入学生账号
LinkUserStudent EntryStudent(LinkUserStudent UserStudentHead);
//删除账号
void AccountSystem_Delete(LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead);
//删除学生账号
LinkUserStudent StudentAccount_Delete(LinkUserStudent UserStudentHead);
//删除教师账号
LinkUserTeacher TeacherAccount_Delete(LinkUserTeacher UserTeacherHead);
//删除管理员账号
LinkUserAdministrator AdministratorAccount_Delete(LinkUserAdministrator UserAdministratorHead);
//修改密码
void Account_ChangePassword(LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead);
//修改学生密码
LinkUserStudent StudentAccount_ChangePassword(LinkUserStudent UserStudentHead);
//修改教师密码
LinkUserTeacher TeacherAccount_ChangePassword(LinkUserTeacher UserTeacherHead);
//修改管理员密码
LinkUserAdministrator AdministratorAccount_ChangePassword(LinkUserAdministrator UserAdministratorHead);
//保存账号
void AccountStore(LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead);
//读取账号
LinkUserAdministrator Administrator_AccountRead(LinkUserAdministrator UserAdministratorHead);
LinkUserTeacher Teacher_AccountRead(LinkUserTeacher UserTeacherHead);
LinkUserStudent Student_AccountRead(LinkUserStudent UserStudentHead);
//登录函数
char login(LinkUserAdministrator AdministratorHead, LinkUserStudent UserStudentHead, LinkUserTeacher UserTeacherHead);
//学生界面菜单
void Student_Begin();
//个人成绩查看
void PersonalGrade_Search(LinkStudent One, LinkCourse CourseHead);
//不及格课程查看
void SearchPersonalFailCourse(LinkStudent One, LinkCourse CourseHead);
//个人学分查看
void PersonalCreadits_Search(LinkStudent One);
//个人信息查看
void PersonalInformation_Search(LinkStudent One);
//个人课程查看
void PersonalCourse_Search(LinkStudent One, LinkStudent StudentHead, LinkCourse CourseHead);
//选课中心
void PersonalCourse_Choose(LinkStudent One, LinkStudent StudentHead, LinkCourse CourseHead, LinkUserAdministrator UserAdministratorHead, LinkUserStudent UserStudentHead, LinkUserTeacher UserTeacherHead);
//个人信息修改
void ModifyPersonalInformation(LinkStudent One);
//学生输入界面
void Input_Student(LinkStudent StudentHead, LinkCourse CourseHead, LinkUserTeacher UserTeacherHead, LinkUserAdministrator UserAdministratorHead, LinkUserStudent UserStudentHead);
//教师界面菜单
void Teacher_Begin();
//教师界面输入
void Input_Teacher(LinkStudent StudentHead, LinkCourse CourseHead, LinkUserTeacher UserTeacherHead, LinkUserAdministrator UserAdministratorHead, LinkUserStudent UserStudentHead);
//添加学生个人
void PushStudent(LinkStudent StudentHead);
//修改学生个人信息
LinkStudent ModifyStudent(LinkStudent StudentHead);
//新建学生链表
LinkStudent CreateStudentList(LinkStudent StudentHead);
//存取学生链表数据
void StoreStudentList(LinkStudent StudentHead);
//删除学生函数
LinkStudent DeleteStudent(LinkStudent StudentHead);
//学生个人信息查看
void SearchInformation(LinkStudent StudentHead);
//学生个人信息录入
LinkStudent PnInformation(LinkStudent StudentHead);
//学生课程链表初始化,设置课程数量且将学号录入
LinkCourse InitCourse(LinkCourse CourseHead, LinkStudent StudentHead);
//添加课程
void AddCourse(LinkCourse CourseHead, LinkStudent StudentHead);
//删除课程函数
LinkCourse DeleteCoursse(LinkCourse CourseHead);
//修改课程信息
void ModifyCourse(LinkCourse CourseHead);
//课程评价
void CourseEvaluation_Operate(LinkCourse CourseHead);
//课程评价查看
void CourseEvaluation_Search(LinkCourse CourseHead);
//按班级录入选课信息
LinkCourse CourseSelection_entry(LinkCourse CourseHead);
//选课学生信息查看
void CourseSelection_view(LinkCourse CourseHead, LinkStudent StudentHead);
//查询学生的选课情况
void SearchStudentCourse(LinkCourse CourseHead, LinkStudent StudentHead);
//查询一个班级的选课情况
void SearchClassCourse(LinkStudent StudentHead, LinkCourse CourseHead);
//查看课程信息
void CourseInformation_View(LinkCourse CourseHead);
//通过编号查看课程信息
void searchcourse(LinkCourse coursehead);
//存取课程链表数据(完成)
void StoreCourseList(LinkCourse CourseHead);
//学生课程成绩录入
void GradeInput(LinkCourse CourseHead, LinkStudent StudentHead);
//学生学分查询
void Creadits_Search(LinkStudent StudentHead);
//查询重修学生的课程
void SearchFailCourse(LinkCourse CourseHead, LinkStudent StudentHead);
//查询课程重修
void Search_CourseRetake(LinkCourse CourseHead, LinkStudent StudentHead);
//按课程录入学生考试成绩。
void GradeInput_ThroughCourse(LinkCourse CourseHead, LinkStudent StudentHead);
//获取课程评价
void GetCourseEvaluation(LinkCourse Course);
//读取课程数据函数
LinkCourse ReadCourseList(LinkStudent StudentHead);
//菜单
void Begin();
//成绩系统菜单
void GradeSystem_Begin(LinkStudent StudentHead, LinkCourse CourseHead, LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead);
//课程系统菜单
void CourseSystem_Begin(LinkStudent StudentHead, LinkCourse CourseHead, LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead);
//信息系统菜单
void InformationSystem_Begin(LinkStudent StudentHead, LinkCourse CourseHead, LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead);
//帐号系统菜单
void AccountSystem_Begin(LinkStudent StudentHead, LinkCourse CourseHead, LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead);
//初始化菜单
void Initialization(LinkStudent StudentHead, LinkCourse CourseHead, LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead);
//读取学生文件数据函数
LinkStudent ReadStudentList();
//查询一个班级的成绩
void SearchClassGrade(LinkStudent StudentHead, LinkCourse CourseHead);
//查询成绩
void SearchCourse(LinkStudent StudentHead, LinkCourse CourseHead);
//数据保存
void StoreData(LinkStudent StudentHead, LinkCourse CourseHead, LinkUserAdministrator UserAdministratorHead, LinkUserStudent UserStudentHead, LinkUserTeacher UserTeacherHead);
//管理员菜单
void Input_Administrator(LinkStudent StudentHead, LinkCourse CourseHead, LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead);
函数定义
#define _CRT_SECURE_NO_WARNINGS
#include stdio.h>
#include "结构体.h"
#include iostream>
#include string>
#includemalloc.h>
#includeconio.h>
using namespace std;
#define PATH1 "StudentData.text"
#define PATH2 "CourseData.text"
#define PATH3 "Teacher_Account.text"
#define PATH4 "Administrator_Account.text"
#define PATH5 "Student_Account.text"
#define InitStudentNum 1000
#define AddStudent 30;
//**************************************基础函数块**************************************
//通过学号找到学生函数
LinkStudent SearchStudent(int StdNum, LinkStudent StudentHead) {
LinkStudent p;
p = StudentHead;
while (p) {
p = p->next;
//先判定是否为空再判定是否是这个学号!
if (!p) {
cout "学号不存在!" endl;
system("pause");
system("cls");
//如果不存在返回NULL标志错误
return NULL;
}
if (p->PersonalInformation.StudentNum == StdNum)break;
//如果找到该学号即返回p
}
return p;
}
//复制课程链表
LinkCourse copyCourse(LinkCourse CourseHead) {
LinkCourse q, p, head1, tem = CourseHead;
head1 = new Course;
*head1 = *tem;
p = head1;
q = p;
tem = tem->next;
while (tem) {
p = new Course;
*p = *tem;
p->next = NULL;
q->next = p;
q = p;
tem = tem->next;
}
return head1;
}
//通过name字符关键词筛选CopyHead中符合条件的节点
LinkCourse NameCourse(LinkCourse CopyHead, char name[]) {
LinkCourse q, p = CopyHead;
q = p;
p = p->next;
int length = strlen(name);
int i = 0, tem, j = 0;
int vis = 0;
//循环整个copy链表
while (p) {
//循环节点的20个字符
while (j 20) {
//如果和name[0]相同即开始比对
if (name[0] == p->SubName[j]) {
//定一个临时值存放 不修改j
tem = j;
for (i = 0; i length; i++) {
//比对不成功即退出
if (name[i] != p->SubName[tem++]) {
break;
}
}
//如果全部比对成功标记为1,留在链表中
if (i == length - 1) { vis = 1; }
}
//比对后 让i归位
i = 0;
//j++继续比对
j++;
//如果到了尽头就退出
if (p->SubName[j] == '')break;
}
if (vis == 0) {
//标记为0 去除p节点
q->next = p->next;
p = q->next;
}
else {
//标记为1 进行下一个搜索
q = p;
p = p->next;
}
vis = 0;
//归位
j = 0;
i = 0;
}
return CopyHead;
}
//通过课程编号查找课程
LinkCourse SearchCourseID(int SubNum, LinkCourse CourseHead) {
LinkCourse p;
p = CourseHead;
while (p) {
p = p->next;
if (!p) {
cout "编号不存在!" endl;
system("pause");
system("cls");
//如果不存在返回NULL标志错误
return NULL;
}
//如果找到该编号即返回p
if (p->SubNum == SubNum)break;
}
return p;
}
//课程关键字搜索得到复制的课程指针
LinkCourse SearchCourse_byword(LinkCourse CourseHead) {
system("cls");
LinkCourse p = CourseHead->next;
cout "请输入操作的课程关键字:" endl;
char name[20];
//输入关键字
cin >> name;
int tnum = 0;
int length = strlen(name);
int i, j = 0;
//查找有多少个 +
for (i = 0; i length; i++) {
if (name[i] == '+')tnum++;
}
tnum += 1;
i = 0;
//copy链表
LinkCourse copyhead = copyCourse(CourseHead);
//循环tnum+1次
while (tnum--) {
char tem[20];
//如果没等于'+'或者''则录入tem
while (name[i] != '+' && name[i] != '') {
tem[j++] = name[i++];
}
//tem录入完后要在后面加一个'';
j++;
tem[j] = '';
//查找tem的链表
copyhead = NameCourse(copyhead, tem);
j = 0;
if (name[i] == '+') { i += 1; }
}
system("cls");
p = copyhead->next;
length = 0;
while (p) {
length++;
p = p->next;
}
copyhead->SubNum = length;
system("cls");
cout "查询到有" copyhead->SubNum "个相关课程" endl;
if (copyhead->SubNum == 0) {
system("pause");
system("cls");
return NULL;
}
int num = 1;
p = copyhead->next;
while (p) {
cout "序号: " num++ endl;
cout "课程编号: " p->SubNum endl;
cout "课程名称: " p->SubName endl;
cout "课程学分: " p->SubCredits endl;
cout "————————————————————" endl;
p = p->next;
}
if (copyhead->SubNum != 1) {
cout "请通过课程序号选择" endl;
cin >> num;
system("cls");
}
else {
num = 1;
}
p = copyhead;
while (num--) {
p = p->next;
if (p == NULL) { cout "课程不存在!" endl; return NULL; }
}
return p;
}
//通过关键词或编号得到课程
LinkCourse GetCourse(LinkCourse CourseHead) {
system("cls");
char judge;
char name[20];
int tnum, num;
int length;
int i, j, id;
LinkCourse copyhead = NULL, p = NULL;
while (1) {
cout "您想要通过什么方式找到课程?" endl;
cout "a:按关键词搜索课程" endl;
cout "b:按编号搜索课程" endl;
cout "#:返回上一层" endl;
cin >> judge;
switch (judge)
{
case'b':
cout "查看的课程编号是" endl;
int SubNum;
cin >> SubNum;
p = SearchCourseID(SubNum, CourseHead);
if (p == NULL) { return NULL; }
system("cls");
cout "查看的课程是: " endl;
cout "课程名称: " p->SubName endl;
cout "课程学分: " p->SubCredits endl;
cout "课程容量: " p->Capacity"/60" endl;
cout "————————————————————" endl;
return p;
case'a':
p = SearchCourse_byword(CourseHead);
if (p == NULL)break;
id = p->SubNum;
p = SearchCourseID(id, CourseHead);
system("cls");
cout "查看的课程是: " endl;
cout "课程名称: " p->SubName endl;
cout "课程学分: " p->SubCredits endl;
cout "————————————————————" endl;
return p;
case'#':
return NULL;
default:cout "请正确输入!" endl;
system("pause");
system("cls");
}
}
}
//**************************************程序登录功能块**************************************
//录入管理员账号
LinkUserAdministrator EntryAdministrator(LinkUserAdministrator AdministratorHead) {
system("cls");
char Judge;
int Flag = 0;
while (1) {
cout "是否要进行操作?(Y/N)" endl;
cin >> Judge;
switch (Judge)
{
case 'Y':case 'y':
Flag = 1;
break;
case 'N':case 'n':
return AdministratorHead;
default:
cout "请重新输入!" endl;
system("pause");
break;
}
if (Flag == 1)break;
}
system("cls");
LinkUserAdministrator q = AdministratorHead, p = new UserAdministrator;
p->next = NULL;
while (1) {
if (q->next == NULL)break;
q = q->next;
}
q->next = p;
cout "管理员成员创建成功!" endl;
cout "请设置账号" endl;
cin >> p->Account;
cout "请设置密码" endl;
cin >> p->Password;
system("pause");
system("cls");
return AdministratorHead;
}
//录入教师账号
LinkUserTeacher EntryTeacher(LinkUserTeacher UserTeacherHead) {
system("cls");
char Judge;
int Flag = 0;
while (1) {
cout "是否要进行操作?(Y/N)" endl;
cin >> Judge;
switch (Judge)
{
case 'Y':case 'y':
Flag = 1;
break;
case 'N':case 'n':
return UserTeacherHead;
default:
cout "请重新输入!" endl;
system("pause");
break;
}
if (Flag == 1)break;
}
system("cls");
LinkUserTeacher q = UserTeacherHead, p = new UserTeacher;
p->next = NULL;
while (1) {
if (q->next == NULL)break;
q = q->next;
}
q->next = p;
cout "教师成员创建成功!" endl;
cout "请设置账号" endl;
cin >> p->Account;
cout "请设置密码" endl;
cin >> p->Password;
system("pause");
system("cls");
return UserTeacherHead;
}
//录入学生账号
LinkUserStudent EntryStudent(LinkUserStudent UserStudentHead) {
system("cls");
char Judge;
int Flag = 0;
while (1) {
cout "是否要进行操作?(Y/N)" endl;
cin >> Judge;
switch (Judge)
{
case 'Y':case 'y':
Flag = 1;
break;
case 'N':case 'n':
return UserStudentHead;
default:
cout "请重新输入!" endl;
system("pause");
break;
}
if (Flag == 1)break;
}
system("cls");
LinkUserStudent q = UserStudentHead, p = new UserStudent;
p->next = NULL;
while (1) {
if (q->next == NULL)break;
q = q->next;
}
q->next = p;
cout "学生成员创建成功!" endl;
cout "请输入您的学号" endl;
cin >> p->StudentNum;
cout "请设置账号" endl;
cin >> p->Account;
cout "请设置密码" endl;
cin >> p->Password;
system("pause");
system("cls");
return UserStudentHead;
}
//删除账号
void AccountSystem_Delete(LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead) {
system("cls");
char Judge;
int Flag = 0;
while (1) {
cout "是否要进行操作?(Y/N)" endl;
cin >> Judge;
switch (Judge)
{
case 'Y':case 'y':
Flag = 1;
break;
case 'N':case 'n':
return;
default:
cout "请重新输入!" endl;
system("pause");
break;
}
if (Flag == 1)break;
}
system("cls");
char judge;
while (1) {
cout "————————————————————" endl;
cout "| 请选择删除账号类型 |" endl;
cout "|———————————————————|" endl;
cout "| a.学生 |" endl;
cout "| b.教师 |" endl;
cout "| c.管理员 |" endl;
cout "————————————————————" endl;
cin >> judge;
switch (judge)
{
case'A':case'a':
UserStudentHead = StudentAccount_Delete(UserStudentHead);
return;
case'b':case'B':
UserTeacherHead = TeacherAccount_Delete(UserTeacherHead);
return;
case'c':case'C':
UserAdministratorHead = AdministratorAccount_Delete(UserAdministratorHead);
return;
default:
break;
}
}
}
//删除学生账号
LinkUserStudent StudentAccount_Delete(LinkUserStudent UserStudentHead) {
system("cls");
cout "请输入要删除的账号" endl;
string Account;
cin >> Account;
LinkUserStudent pre, One = UserStudentHead->next;
pre = UserStudentHead;
while (1) {
if (!One->Account.compare(Account)) {
break;
}
pre = One;
One = One->next;
if (One == NULL) {
cout "不存在该账户!" endl;
system("pause");
return UserStudentHead;
}
}
cout "请输入要删除的账号密码" endl;
string Password;
cin >> Password;
if (!One->Password.compare(Password)) {
pre->next = One->next;
cout "删除成功!" endl;
system("pause");
return UserStudentHead;
}
else {
cout "密码错误!" endl;
system("pause");
return UserStudentHead;
}
}
//删除教师账号
LinkUserTeacher TeacherAccount_Delete(LinkUserTeacher UserTeacherHead) {
system("cls");
cout "请输入要删除的账号" endl;
string Account;
cin >> Account;
LinkUserTeacher pre, One = UserTeacherHead->next;
pre = UserTeacherHead;
while (1) {
if (!One->Account.compare(Account)) {
break;
}
pre = One;
One = One->next;
if (One == NULL) {
cout "不存在该账户!" endl;
system("pause");
return UserTeacherHead;
}
}
cout "请输入要删除的账号密码" endl;
string Password;
cin >> Password;
if (!One->Password.compare(Password)) {
pre->next = One->next;
cout "删除成功!" endl;
system("pause");
return UserTeacherHead;
}
else {
cout "密码错误!" endl;
system("pause");
return UserTeacherHead;
}
}
//删除管理员账号
LinkUserAdministrator AdministratorAccount_Delete(LinkUserAdministrator UserAdministratorHead) {
system("cls");
cout "请输入要删除的账号" endl;
string Account;
cin >> Account;
LinkUserAdministrator pre, One = UserAdministratorHead->next;
pre = UserAdministratorHead;
while (1) {
if (!One->Account.compare(Account)) {
break;
}
pre = One;
One = One->next;
if (One == NULL) {
cout "不存在该账户!" endl;
system("pause");
return UserAdministratorHead;
}
}
cout "请输入要删除的账号密码" endl;
string Password;
cin >> Password;
if (!One->Password.compare(Password)) {
pre->next = One->next;
cout "删除成功!" endl;
system("pause");
return UserAdministratorHead;
}
else {
cout "密码错误!" endl;
system("pause");
return UserAdministratorHead;
}
}
//修改密码
void Account_ChangePassword(LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead) {
system("cls");
char Judge;
int Flag = 0;
while (1) {
cout "是否要进行操作?(Y/N)" endl;
cin >> Judge;
switch (Judge)
{
case 'Y':case 'y':
Flag = 1;
break;
case 'N':case 'n':
return;
default:
cout "请重新输入!" endl;
system("pause");
system("cls");
break;
}
if (Flag == 1)break;
}
system("cls");
char judge;
while (1) {
cout "————————————————————" endl;
cout "| 请选择账号类型 |" endl;
cout "|———————————————————|" endl;
cout "| a.学生 |" endl;
cout "| b.教师 |" endl;
cout "| c.管理员 |" endl;
cout "————————————————————" endl;
cin >> judge;
switch (judge)
{
case'A':case'a':
UserStudentHead = StudentAccount_ChangePassword(UserStudentHead);
return;
case'b':case'B':
UserTeacherHead = TeacherAccount_ChangePassword(UserTeacherHead);
return;
case'c':case'C':
UserAdministratorHead = AdministratorAccount_ChangePassword(UserAdministratorHead);
return;
default:
break;
}
}
}
//修改学生密码
LinkUserStudent StudentAccount_ChangePassword(LinkUserStudent UserStudentHead) {
system("cls");
char Judge;
int Flag = 0;
while (1) {
cout "是否要进行操作?(Y/N)" endl;
cin >> Judge;
switch (Judge)
{
case 'Y':case 'y':
Flag = 1;
break;
case 'N':case 'n':
return UserStudentHead;
default:
cout "请重新输入!" endl;
system("pause");
system("cls");
break;
}
if (Flag == 1)break;
}
system("cls");
cout "请输入您的账号" endl;
string Account;
cin >> Account;
LinkUserStudent One = UserStudentHead->next;
while (1) {
if (!One->Account.compare(Account)) {
break;
}
One = One->next;
if (One == NULL) {
cout "不存在该账户!" endl;
system("pause");
return UserStudentHead;
}
}
cout "请输入要原账户的账号密码:" endl;
string Password;
cin >> Password;
if (!One->Password.compare(Password)) {
cout "请输入新的账号密码:" endl;
cin >> One->Password;
cout "修改成功!" endl;
system("pause");
}
else {
cout "密码错误!" endl;
system("pause");
return UserStudentHead;
}
}
//修改教师密码
LinkUserTeacher TeacherAccount_ChangePassword(LinkUserTeacher UserTeacherHead) {
system("cls");
char Judge;
int Flag = 0;
while (1) {
cout "是否要进行操作?(Y/N)" endl;
cin >> Judge;
switch (Judge)
{
case 'Y':case 'y':
Flag = 1;
break;
case 'N':case 'n':
return UserTeacherHead;
default:
cout "请重新输入!" endl;
system("pause");
break;
}
if (Flag == 1)break;
}
system("cls");
cout "请输入您的账号" endl;
string Account;
cin >> Account;
LinkUserTeacher One = UserTeacherHead->next;
while (1) {
if (!One->Account.compare(Account)) {
break;
}
One = One->next;
if (One == NULL) {
cout "不存在该账户!" endl;
system("pause");
return UserTeacherHead;
}
}
cout "请输入要原账户的账号密码:" endl;
string Password;
cin >> Password;
if (!One->Password.compare(Password)) {
cout "请输入新的账号密码:" endl;
cin >> One->Password;
cout "修改成功!" endl;
system("pause");
}
else {
cout "密码错误!" endl;
system("pause");
return UserTeacherHead;
}
}
//修改管理员密码
LinkUserAdministrator AdministratorAccount_ChangePassword(LinkUserAdministrator UserAdministratorHead) {
system("cls");
char Judge;
int Flag = 0;
while (1) {
cout "是否要进行操作?(Y/N)" endl;
cin >> Judge;
switch (Judge)
{
case 'Y':case 'y':
Flag = 1;
break;
case 'N':case 'n':
return UserAdministratorHead;
default:
cout "请重新输入!" endl;
system("pause");
system("cls");
break;
}
if (Flag == 1)break;
}
system("cls");
cout "请输入您的账号" endl;
string Account;
cin >> Account;
LinkUserAdministrator One = UserAdministratorHead->next;
while (1) {
if (!One->Account.compare(Account)) {
break;
}
One = One->next;
if (One == NULL) {
cout "不存在该账户!" endl;
system("pause");
return UserAdministratorHead;
}
}
cout "请输入要原账户的账号密码:" endl;
string Password;
cin >> Password;
if (!One->Password.compare(Password)) {
cout "请输入新的账号密码:" endl;
cin >> One->Password;
cout "修改成功!" endl;
system("pause");
}
else {
cout "密码错误!" endl;
system("pause");
return UserAdministratorHead;
}
}
//保存账号
void AccountStore(LinkUserAdministrator UserAdministratorHead, LinkUserTeacher UserTeacherHead, LinkUserStudent UserStudentHead) {
LinkUserAdministrator p = UserAdministratorHead;
LinkUserTeacher q = UserTeacherHead;
LinkUserStudent r = UserStudentHead;
cout "正在存储数据" endl;
if (UserAdministratorHead->next == NULL) { cout "管理员账户数据不存在!" endl; return; }
if (UserTeacherHead->next == NULL) { cout "教师账户数据不存在!" endl; return; }
if (UserStudentHead->next == NULL) { cout "学生账户数据不存在!" endl; return; }
FILE* fp = fopen(PATH4, "wb");
if (fp == NULL) { cout "储存管理员数据失败!" endl; return; }
//写入时也要把头节点写进去
while (p != NULL) {
fwrite(p, sizeof(UserAdministrator), 1, fp);
p = p->next;
}
cout "存储管理员数据成功!" endl;
fclose(fp);
fp = fopen(PATH3, "wb");
if (fp == NULL) { cout "储存教师数据失败!" endl; return; }
//写入时也要把头节点写进去
while (q != NULL) {
fwrite(q, sizeof(UserTeacher), 1, fp);
q = q->next;
}
cout "存储教师数据成功!" endl;
fclose(fp);
fp = fopen(PATH5, "wb");
if (fp == NULL) { cout "储存学生数据失败!" endl; return; }
//写入时也要把头节点写进去
while (r != NULL) {
fwrite(r, sizeof(UserStudent), 1, fp);
r = r->next;
}
cout "存储学生数据成功!" endl;
fclose(fp);
fp = NULL;
system("pause");
}
//读取账号
LinkUserAdministrator Administrator_AccountRead(LinkUserAdministrator UserAdministratorHead) {
cout "正在读取管理员数据!" endl;
LinkUserAdministrator p1, p2;
UserAdministratorHead = new UserAdministrator;
p2 = UserAdministratorHead;
UserAdministratorHead->next = NULL;
FILE* fp = fopen(PATH4, "rb");
int i;
if (fp == NULL) {
cout "管理员数据文件不存在!" endl;
cout "将为您初始化,请根据信息进行输入!" endl;
UserAdministratorHead = EntryAdministrator(UserAdministratorHead);
system("cls");
}
else {
//读取时先读取第一个头节点
fread(UserAdministratorHead, sizeof(*UserAdministratorHead), 1, fp);
p1 = new UserAdministrator;
i = 0;
while ((fread(p1, sizeof(*p1), 1, fp)) == 1) {
i++;
p1->next = NULL;
p2->next = p1;
p2 = p1;
p1 = new UserAdministrator;
}
if (i == 0) { cout