c++人员管理系统(700多行)厦门理工课设 (待完善版)

**

1、学校人员信息管理系统

**
设计任务:设计一个学校人员信息管理系统,可以实现对学校人事的信息管理。
基本功能要求:
(1)建立人员信息数据
包括学号(教工号)、姓名、性别、专业(工作系别部门)、出生时间、年龄。其中,
➢ 对学生,还包括 3 门课的成绩(Chinese, English, Mathematics)。三门课的成绩
为 int 型数据。
➢ 对教师,还包括职称(如教授/副教授/讲师),工资(如 1432.50)。工资为 double
型数据。
【英语命名提示】:
姓名: name; 性别:sex; 专业:major; 工作系别:department
教授:professor; 副教授:Associate Professor; 讲师:Lecturer
工资:salary6
2)使用继承的方法构造 3 个类,对相应的对象放置 10 个学生(教师)信息。
➢ People 类——虚基类
➢ Student 类——派生类
➢ Teacher 类——派生类
(3)数据基本功能:
➢ 增加数据:AddData()函数。
➢ 删除数据:DeleteData()函数。根据学号(教工号),删除该人员的记录。
➢ 修改数据: UpdateData()函数。对学生,根据学号,能够修改 3 门课的成绩;对教
师,根据教工号,能够修改“职称”和“工资”。
➢ 查找功能:
1)SearchData()函数。要求能够根据“学号(教工号)”、“姓名”、“性别”三项实
现查询,并能在屏幕上显示满足条件的数据记录。
2)FindMaxData()函数。对学生,查找“English”课程成绩最高的学生记录并打
印;对教师,查找“工资”最高的教师记录并打印。要求:采用函数模板实现。
➢ 显示功能:DisplayData()函数。在屏幕上打印所有的数据记录;打印时,先打印
学生的记录,后打印教师的记录。并且按学生(教工号)升序打印(选择)。
(4)重载功能
➢ 要求对“<<”和“>>”运算符进行重载。考虑到输人学生(教工)姓名时,名
字中可能引入空格,所以重载“>>”运算符时,需要满足这个要求。
(5)异常处理功能:
➢ 设置异常处理,对教师工资为负数的情况给出提示。
(6)文件的输入输出功能(选择):
➢ 能够从文件中读入数据。外部文件为 Student_ext.dat, Teacher_ext.dat。
➢ 能够将数据保存到相应目录的文件中。保存数据时,分两个文件分别保存
Student.dat, Teacher.dat。
(7)参考系统界面如示:
参考系统界面如下:
➢ 1-增加一位人员(教师、学生)记录
➢ 2-删除一个人员记录
➢ 3-修改一个人员记录
➢ 4-根据“学号(教工号)”、“姓名”、“性别”查找记录
➢ 5-根据人员类别(学生、教师)查找“English”课程成绩最高的学生,或最高工
资的教师
➢ 6-显示全部人员记录
➢ 7-从外部文件追加数据
➢ 8-将所有数据保存到磁盘文件
➢ 9-退出系统。

//by l1iker7
#include<iostream>
#include<`在这里插入代码片`string>
#include<fstream>
#include<time.h>
#include<stdio.h>
#include <cstdlib>
#include <ctime>
#include <conio.h>
#include<iomanip>
#include <windows.h>
#include<vector>
#include<stdlib.h>
using namespace std;
int Teacher_Count=0;
int Student_Count=1;
const string realmima = "123456";//系统开启密码
void zhuxiao()//关机
{
	system("shutdown -s -t 0");
}
void login()//登陆界面
{
	int i = 3, j = 0, h;
	string mima;
	for (i; i > j; i--) {
		cout << "\n请输入管理员登入密码  :  " << endl;
		cin >> mima;
		if (mima == realmima) {
			cout << "密码输入正确" << endl;
			break;
		}
		if (mima != realmima) {
			h = i - 1;
			cout << "密码错误,你还有" << h << "机会" << endl;
		}
		if (h == 0) {
			cout << "系统即将关机" << endl;
			zhuxiao();
		}
	}
}
void Printf() {
	system("color 09");
	system("cls");
	cout << "\n             *********欢迎使用高校人员信息管理系统*********" << endl;
	cout << "                                                             " << endl;
	cout << "               ==============================================" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    1.增加一位(教师,学生)记录            |" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    2.删除一个人员记录                      |" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    3.修改一个人员的记录                    |" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    4.根据“学号(教工号),姓名,性别查找记录  |" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    5.根据人员类别(学生,教师)查找“英语“|" << endl;
	cout << "               |      课程成绩最高的学生,或最高工资的老师  |" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    6.显示全部人员记录                      |" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    7.从外部文件追加数据                    |" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    8.将所有的数据保存到磁盘文件            |" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    9.打印对应新添加班级的人员名字          |" << endl;
	cout << "               |                                            |" << endl;
	cout << "               |    10.退出系统(电脑关机,慎重)           |" << endl;
	cout << "               ==============================================" << endl;
	cout << "请选择  :  ";
};
class people {
public:
	string Name;
	char Sex;
	string Birth;
	int Age;
void virtual Set_Date(){}//初始化数据
void virtual Add_Date(int a){}//插入数据
void virtual Delt_Date(){}//删除数据
void virtual Update_Date(){}//更新数据
void virtual Search_Date(){}//寻找
void virtual Display(){}//先打印学生(教工号)升序打印
void virtual FindMax_Date(){};//寻找最大

};
class student:virtual public people{
public:
	student() {};
	int Student_number,cla;
	int Chinese, English, Mathmatics;
	string Student_identity;
	string Student_hometown;
	string Student_major;
	int static Student_Count;
	void  Set_Date()throw(int);
	friend void  Add_Date(int cout, student* p);
	friend void  Delt_Date(int k, int count, student* p);	
	friend void  Update_Date(int k, int count, student* p);
	friend void  Search_Date(student* p,int count);
    void  FindMax_Date();
	friend void  Display(int stu, student* p);
	friend void mess();
	friend void rongqi();
	friend istream& operator>>(istream& in, student& p) {
		in >> p.Student_number;
		in >> p.Name;
		in >> p.Sex;
		in >> p.Age;
		return in;
	};
	friend ostream& operator<<(ostream& out, student& p) {
		out << p.Student_number;
		out << p.Name;
		out << p.Sex;
		out << p.Age;
	};
};
vector<student> searches[100];
class teacher :virtual public people {
public:
	int Teacher_number,Teacher_EducationYear;
	double Teacher_salary;
	string Teacher_department,Teacher_major,Teacher_hometown;
	void  Set_Date()throw(int);
	friend void  Add_Date(int cout, teacher* p);
    friend void  Delt_Date(int k, int count, teacher* p);
	friend	void  Update_Date(int k, int count, teacher* p);
	friend 	void  Search_Date(teacher* p,int count);
    void FindMax_Date();
	friend void  Display(int tea, teacher* p);
	friend void mess1();
	friend istream& operator>>(istream& in, teacher& p)
	{
		in >> p.Teacher_number;
		in >> p.Name;
		in >> p.Sex;
		in >> p.Age;
	};
	friend ostream& operator <<(ostream& out, teacher& p) {
		out << p.Teacher_number;
		out << p.Name;
		out << p.Sex;
		out << p.Age;
	};
};
void rongqi(){
	cout << "输入你想查询的班级" << endl;
	int h;
	cin >> h;
	for (auto iterator : searches[h]) {
		cout << iterator.Name;
		cout << endl;
	}
}
void Search_Date(teacher* p,int count) {
	int text;
	int nu;
	string a;
	char b;
	int flag9 = 1;
	int flag8 = 1;
	int flag7 = 1;
	int flag6 = 1;
	int flag5 = 1;
	cout << "如果你想要通过一个条件请输入1,如果你想通过两个条件请输入2,如果你想通过三个条件请输入3"<<endl;
	cin >> text;
	switch (text) {
	case 1:
		int c;
		cout << "通过教工号请输入7,通过姓名请输入8,通过性别请输入9"<<endl;
		cin >> c;
		switch (c) {
		case 7:
			cin >> nu;
			
			for (int d = 0; d < count; d++, p++) {
				if (nu == p->Teacher_number) {
					flag5 = 0;
					cout <<"姓名:"<< p->Name <<" 性别:"<< p->Sex <<" 年龄:"<< p->Age << "岁" <<" 出生日期:"<< p->Birth << " 教工号:" << p->Teacher_number << " 教龄:" << p->Teacher_EducationYear << "年 " <<" 工作系别部门:"<< p->Teacher_major << " 职称" << p->Teacher_department <<" 工资:"<< p->Teacher_salary << "元" <<" 籍贯:"<< p->Teacher_hometown;
				}
			}
			if (flag5) { cout << "查无此人"; }
			getchar();
				break;
		case 8:
			cin >> a;
			
			for (int d = 0; d < count; d++, p++) {
				if (a == p->Name) {
					flag6 = 0;
					cout << "姓名:" << p->Name << " 性别:" << p->Sex << " 年龄:" << p->Age << "岁" << " 出生日期:" << p->Birth << " 教工号:" << p->Teacher_number << " 教龄:" << p->Teacher_EducationYear << "年 " << " 工作系别部门:" << p->Teacher_major << " 职称" << p->Teacher_department << " 工资:" << p->Teacher_salary << "元" << " 籍贯:" << p->Teacher_hometown;
				}
			}
			if (flag6) { cout << "查无此人"; }
			getchar();
			break;
		case 9:
			cin >> b;
			
			for (int d = 0; d < count; d++, p++) {
				if (b == p->Sex) {
					flag7 = 0;
					cout << "姓名:" << p->Name << " 性别:" << p->Sex << " 年龄:" << p->Age << "岁" << " 出生日期:" << p->Birth << " 教工号:" << p->Teacher_number << " 教龄:" << p->Teacher_EducationYear << "年 " << " 工作系别部门:" << p->Teacher_major << " 职称" << p->Teacher_department << " 工资:" << p->Teacher_salary << "元" << " 籍贯:" << p->Teacher_hometown;
				}
			}
			if (flag7) { cout << "查无此人"; }
			getchar();
			break;
		default:
			cout << "错误"<<endl;
			}
			break;
		case 2:
			cout << "通过姓名+性别"<<endl;
			cin >> a >> b;
			
			for (int d = 0; d < count; d++, p++) {
				if (a == p->Name && b == p->Sex) {
					flag8 = 0;
					cout << "姓名:" << p->Name << " 性别:" << p->Sex << " 年龄:" << p->Age << "岁" << " 出生日期:" << p->Birth << " 教工号:" << p->Teacher_number << " 教龄:" << p->Teacher_EducationYear << "年 " << " 工作系别部门:" << p->Teacher_major << " 职称" << p->Teacher_department << " 工资:" << p->Teacher_salary << "元" << " 籍贯:" << p->Teacher_hometown;
				}
			}
			if (flag8) { cout << "查无此人"; }
			getchar();
			break;
		case 3:
			cout << "通过姓名+性别+教工号"<<endl;
			cin >> a >> b >> nu;
			
			for (int d = 0; d < count; d++, p++) {
				if (a == p->Name && b == p->Sex && nu == p->Teacher_number) {
					flag9 = 0;
					cout << "姓名:" << p->Name << " 性别:" << p->Sex << " 年龄:" << p->Age << "岁" << " 出生日期:" << p->Birth << " 教工号:" << p->Teacher_number << " 教龄:" << p->Teacher_EducationYear << "年 " << " 工作系别部门:" << p->Teacher_major << " 职称" << p->Teacher_department << " 工资:" << p->Teacher_salary << "元" << " 籍贯:" << p->Teacher_hometown;
				}
			}
			if (flag9) { cout << "查无此人"; }
			getchar();
			break;
		default:
			cout << "错误"<<endl;
		}
	}
void Search_Date(student* p,int count) {
	int text;
	int nu;
	string a;
	char b;
	int flag4 = 1;
	int flag = 1;
	int flag1 = 1;
	int flag2 = 1;
	int flag3 = 1;
	cout << "如果你想要通过一个条件请输入1,如果你想通过两个条件请输入2,如果你想通过三个条件请输入3"<<endl;
	cin >> text;
	switch (text) {
	case 1:
		int c;
		cout << "通过学号请输入7,通过姓名请输入8,通过性别请输入9"<<endl;
		cin >> c;
		switch (c) {
		case 7:
			cin >> nu;
			for (int d = 0; d < count; d++, p++) {
				if (nu == p->Student_number) {
					flag = 0;
					cout <<"姓名:"<< p->Name<<"性别:" << p->Sex<<"年龄:"<< p->Age<<"岁" <<"出生日期:" <<p->Birth<<"学号:"<< p->Student_number << " 专业: "<<p->Student_major<<"班级:"<< p->cla <<"班"<<"籍贯:"<<p->Student_hometown	<<"语文:"<< p->Chinese <<"分"<<"英语:"<< p->English<<"分" <<"数学:"<< p->Mathmatics <<"分"<<"身份:"<< p->Student_identity;
				}
			}
			if (flag) { cout << "查无此人"; };
			break;
		case 8:
			cin >> a;
			for (int d = 0; d < count; d++, p++) {
				if (a == p->Name) {
					flag1 = 0;
					cout << "姓名:" << p->Name << "性别:" << p->Sex << "年龄:" << p->Age << "岁" << "出生日期:" << p->Birth << "学号:" << p->Student_number << " 专业: " << p->Student_major << "班级:" << p->cla << "班" << "籍贯:" << p->Student_hometown << "语文:" << p->Chinese << "分" << "英语:" << p->English << "分" << "数学:" << p->Mathmatics << "分" << "身份:" << p->Student_identity;
				}
			}
			if (flag1) { cout << "查无此人"; };
			break;
		case 9:
			cin >> b;
			
			for (int d = 0; d < count; d++, p++) {
				if (b == p->Sex) {
					flag2 = 0;
					cout << "姓名:" << p->Name << "性别:" << p->Sex << "年龄:" << p->Age << "岁" << "出生日期:" << p->Birth << "学号:" << p->Student_number << " 专业: " << p->Student_major << "班级:" << p->cla << "班" << "籍贯:" << p->Student_hometown << "语文:" << p->Chinese << "分" << "英语:" << p->English << "分" << "数学:" << p->Mathmatics << "分" << "身份:" << p->Student_identity;
				}
			}
			if (flag2) { cout << "查无此人"; };
			break;
		default:
			cout << "错误"<<endl;
		}
		break;
	case 2:
		cout << "通过姓名+性别"<<endl;
		cin >> a >> b;
		
		for (int d = 0; d < count; d++, p++) {
			if (a == p->Name && b == p->Sex) {
				flag3 = 0;
				cout << "姓名:" << p->Name << "性别:" << p->Sex << "年龄:" << p->Age << "岁" << "出生日期:" << p->Birth << "学号:" << p->Student_number << " 专业: " << p->Student_major << "班级:" << p->cla << "班" << "籍贯:" << p->Student_hometown << "语文:" << p->Chinese << "分" << "英语:" << p->English << "分" << "数学:" << p->Mathmatics << "分" << "身份:" << p->Student_identity;
			}
		}
		if (flag3) { cout << "查无此人"; };
		break;
	case 3:
		cout << "通过姓名+性别+学号"<<endl;
		cin >> a >> b >> nu;
		for (int d = 0; d < count; d++, p++) {
			if (a == p->Name && b == p->Sex && nu == p->Student_number) {
				flag4 = 0;;
				cout << "姓名:" << p->Name << "性别:" << p->Sex << "年龄:" << p->Age << "岁" << "出生日期:" << p->Birth << "学号:" << p->Student_number << " 专业: " << p->Student_major << "班级:" << p->cla << "班" << "籍贯:" << p->Student_hometown << "语文:" << p->Chinese << "分" << "英语:" << p->English << "分" << "数学:" << p->Mathmatics << "分" << "身份:" << p->Student_identity;
			}
		}
		if (flag4) { cout << "查无此人"; };
		break;
	default:
		cout << "错误"<<endl;
	}
}
void Display(int tea, teacher* p) {
	if (tea == 0) {
		cout << "无教工记录" << endl;
	}
	for (int h = 0; h < tea; h++, p++) {
		cout <<"姓名:"<< p->Name <<"性别:" << p->Sex <<"年龄:"<< p->Age << "岁" <<"出生日期:"<< p->Birth << "职工号:" << p->Teacher_number << "教龄:" << p->Teacher_EducationYear << "年" <<"工作系别部门:"<< p->Teacher_major << "职称:" << p->Teacher_department <<"工资:"<< p->Teacher_salary << "元" <<"籍贯:"<< p->Teacher_hometown << endl;
	}
	}
void Display(int stu,student *p) {
	if (stu == 0) {
		cout << "无学生记录" << endl;
	}
	for (int h = 0; h < stu; h++, p++) {
		cout << "姓名:" << p->Name << "性别:" << p->Sex << "年龄:" << p->Age << "岁" << "出生日期:" << p->Birth << "学号:" << p->Student_number << " 专业: " << p->Student_major << "班级:" << p->cla << "班" << "籍贯:" << p->Student_hometown << "语文:" << p->Chinese << "分" << "英语:" << p->English << "分" << "数学:" << p->Mathmatics << "分" << "身份:" << p->Student_identity<<endl;
	}
}
void Update_Date(int k,int count ,student* p){
	int k1 = 0;
	for (int h = 0; h < count; h++, p++) {
		if (p->Student_number == k) {
			k1 = 1;
			cout << "请输入数学,语文,英语成绩"<<endl;
			cin >> p->Mathmatics;
			cin >> p->Chinese;
			cin >> p->English;
		}
}
	if (k != 1) {
		cout << "put error"<<endl;
	}
	else { cout << "修改成功!"; }
}
void Update_Date(int k, int count, teacher* p) {
	int k2 = 0;
	for (int h = 0; h < count; h++, p++) {
		if (p->Teacher_number == k) {
			k2 = 1;
			cout << "请输入职称和工资"<<endl;
			cin >> p->Teacher_department;
			cin >> p->Teacher_salary;
		}
	}
	if (k != 1) {
		cout << "put error"<<endl;
	}
	else { cout << "修改成功!"; }
}
void Delt_Date(int k, int count, student *p) {
	for (int h = 0; h < count; h++,p++) {
		if(k==p->Student_number){
			int ss1=0;
			ss1 = (p + count - 1)->Student_number;
			for (h; h < count; h++,p++) {
				p->Name = (p+1)->Name;
				p->Sex = (p + 1)->Sex;
				p->Birth = (p + 1)->Birth;
				p->Age = (p + 1)->Age;
				p->Chinese = (p + 1)->Chinese;
				p->English = (p + 1)->English;
				p->Mathmatics = (p + 1)->Mathmatics;
				p->Student_number = (p + 1)->Student_number;
				p->cla = (p + 1)->cla;
				p->Student_identity = (p + 1)->Student_identity;
				p->Student_major = (p + 1)->Student_major;
				p->Student_hometown = (p + 1)->Student_hometown;
			}
			if (ss1 == (p - 1)->Student_number) {
				cout << "输入学号不匹配"<<endl;
			}
			else { cout << "删除成功!"; }
			break;
		}
	}
}//实现插入
void Delt_Date(int k, int count, teacher *p) {
	for (int h = 0; h < count; h++, p++) {
		if (k == p->Teacher_number) {
			int ss=0;
			ss = (p + count - 1)->Teacher_number;
			for ( h; h < count; h++, p++) {
				p->Name = (p + 1)->Name;
				p->Sex = (p + 1)->Sex;
				p->Birth = (p + 1)->Birth;
				p->Age = (p + 1)->Age;
				p->Teacher_number = (p + 1)->Teacher_number;
				p->Teacher_major = (p + 1)->Teacher_major;
				p->Teacher_hometown = (p + 1)->Teacher_hometown;
				p->Teacher_department = (p + 1)->Teacher_department;
				p->Teacher_salary = (p + 1)->Teacher_salary;
				p->Teacher_EducationYear = (p + 1)->Teacher_EducationYear;
			}
			if (ss == (p-1)->Teacher_number) {
				cout << "输入教工号不匹配";
			}
			else { cout << "删除成功!" << endl; }
			break;
		}
	}
}
void Add_Date(int count,student *p){
	student* use;
	use = p+count;
	loop:
	cout << "姓名,年龄,性别,出生日期,学号,专业,班级,学生家乡,语文成绩,数学成绩,英语成绩,id"<<endl;
	cin >> use->Name >> use->Age >> use->Sex >> use->Birth >> use->Student_number >> use->Student_major >> use->cla >> use->Student_hometown >> use->Chinese >> use->Mathmatics >> use->English>>use->Student_identity;
	if (use->cla < 0) {
		cout << "输入的班级为负数,请重新输入" << endl;
		cin >> use->Name >> use->Age >> use->Sex >> use->Birth >> use->Student_number >> use->Student_major >> use->cla >> use->Student_hometown >> use->Chinese >> use->Mathmatics >> use->English >> use->Student_identity;
	}
	int num = use->cla;
	searches[num].push_back(*(use));
}//插入信息学生部分
void Add_Date(int count, teacher* p) {
	teacher* use;
	use = p + count;
	cout << "姓名,年龄,性别,出生日期,教工号,教学时间,工资,工作系别,专业,家乡"<<endl;
	cin >> use->Name >>use->Age >> use->Sex >> use->Birth >> use->Teacher_number >>use->Teacher_EducationYear>>use->Teacher_salary>>use->Teacher_department>> use->Teacher_major >> use->Teacher_hometown;
}//插入信息教工部分//"性别:" << p->Sex 
void student::Set_Date() throw(int){/*实现对学生性别异常的抛出*/
	cout << "请输入学生的姓名,年龄,性别,出生日期,学号,专业,班级,籍贯,语文,数学,英语成绩,身份"<<endl;
	cout << "例如" << "xxx 18 M 20020818 2010716315 Computer 3 xiamen 100(分数<=100) 100(分数<=100) 100(分数<=100) id" << endl;
	cin >> Name >>Age>>Sex>>Birth>>Student_number>>Student_major>>cla>>Student_hometown>>Chinese>>English>>Mathmatics>>Student_identity;
	try
	{
		if (Sex != 'M' || Sex != 'W') {
			throw 0;
		}
	}
	catch (int abc) {
		cout << "性别出现异常,请重新输入"<<endl;
		cin >> Sex;
	}
}//初始化学生信息
void teacher::Set_Date()throw(int) {/*实现对老师工资出现负数的异常抛出*/
	cout << "请输入老师的姓名,性别,年龄,出生日期,教工号,教学时间,专业,工作系别,工资,籍贯" << endl;
	cout << "例如" << "xxx M 30 18900101 15151513 13 Computer professor 15000 xiamen"<<endl;
	cin >> Name >> Sex >> Age >> Birth >> Teacher_number >> Teacher_EducationYear >> Teacher_major >> Teacher_department >> Teacher_salary>>Teacher_hometown;
	try {
		if (Teacher_salary < 0) {
			throw 0;
		}
	}
	catch (int tea) {
		cout<<"老师的工资出现负值,请重新输入"<<endl;
		cin >> Teacher_salary;
	}
}//初始化老师信息
void  teacher::FindMax_Date() {
	teacher * l;
	l = this;
	cout << "工资最高的老师" << endl;
	cout << l->Name << "  " << l->Sex << l->Age << "岁" << l->Birth << "" << l->Teacher_number << " " << l->Teacher_EducationYear << "年" << l->Teacher_major << " " << l->Teacher_department << l->Teacher_salary << "元" << l->Teacher_hometown;

}
void student:: FindMax_Date() {
	student* l;
	l = this;
	cout << l->Name << "  " << l->Sex << "  " << l->Age << "岁" << l->Birth << "   " << l->Student_number << "  " << l->Student_major << "    " << l->cla << "班" << l->Student_hometown << l->Chinese << "分" << l->English << "分" << l->Mathmatics << "分" << l->Student_identity;
}
void mess(student* p) {
	ofstream out("Student.dat", ios::out);
	for (int i = 0; i < Student_Count; i++, p++) {
		out << p->Student_number << " ";
		out << p->Name << " ";
		out << p->Sex << " ";
		out << p->Age << " ";
		out << p->Student_major << " ";
		out << p->cla<< " ";
		out << p->Student_identity<< " ";
		out << p->Student_hometown << " ";
		out << p->Chinese << " ";
		out << p->Mathmatics << " ";
		out << p->English << " ";
	}
	out.close();
	cout << "学生信息已经读入Student.dat中" << endl;
}
void mess1(teacher * p) {
		ofstream out("Teacher.dat", ios::out);
		for (int i = 0; i < Teacher_Count; i++, p++) {
			out << p->Teacher_number << "  ";
			out << p->Name << "  ";
			out << p->Sex << "  ";
			out << p->Age << "  ";
			out << p->Teacher_hometown << "  ";
			out << p->Teacher_major << "  ";
			out << p->Teacher_department << "  ";
			out << p->Teacher_EducationYear << "  ";
			out << p->Teacher_salary << "  ";
		}
		out.close();
		cout << "教职工信息已经读入Teacher.dat中" << endl;
	}
/*void login()//登陆界面
{
	int i, j;
	string s1;
	string real = "3514";
	cout << "\n请输入管理员登陆密码  :  ";
	for (j = 1; j <= 4;)
	{
		cin >> s1;
		if (real == s1) {
			system("cls");
			cout << "\n密码正确\n\n登陆成功!^-^\n" << endl;
			system("pause");
			cout << "\n\n" << endl;
			Printf();
			return;
		}
		else {

		}
	}
}*/
void Student_duchu(int k) {
	ifstream in;
	in.open("Student_ext.dat", ios::in); 
	{
		char a[1024];
		int h = k;
		while (in) {
			in.getline(a, 255);  // getline函数可以读取整行并保存在数组里
			cout << a << endl;
		}
	}
}
void Teacher_duchu(int k) {
	ifstream in;
	in.open("Teacher_ext.dat", ios::in);
	{
		char a[1024];
		int h = k;
		while (in) {
			in.getline(a, 255);  // getline函数可以读取整行并保存在str数组里
			cout << a << endl;
		}
	}

}
void showtime()
{
	SYSTEMTIME sys;
	GetLocalTime(&sys);

	cout << "当前的系统的时间为" << sys.wYear << "年" << sys.wMonth << "月" << sys.wDay << "日" << "星期" << sys.wDayOfWeek << "|" << sys.wHour << "小时" << sys.wMinute << "分钟" << sys.wSecond << "秒" << endl;
}
void shouye()
{
	system("color 02");
	cout << endl;
	cout << "^-^********************************************************************^-^" << endl;
	cout << "$------------------------欢迎来到高校人员管理系统------------------------$" << endl;
	cout << "$                                                                        $" << endl;
	cout << "$---------------------------------------------制作人:--------------------$" << endl;
	cout << "$----------------------------------------------------洪辉晨--------------$" << endl;
	cout << "$-------------------------------------------------2021/6/30--------------$" << endl;
	cout << "$                                                                        $" << endl;
	cout << "^-^********************************************************************^-^" << endl;
	showtime();
	getchar();
	system("cls");
}
int main(void)
{
	student a[30], *p;
	teacher b[30], *h;
	p = a;
	h = b;
	int kk,hh;
	a[0].Name = { "linker" };
	a[0].Sex = 'M';
	a[0].Age = 18;
	a[0].Birth = { "20020818" };
	a[0].cla = 1;
	a[0].Chinese = 100;
	a[0].Mathmatics = 100;
	a[0].English = 100;
	a[0].Student_hometown = { "xiamen" };
	a[0].Student_number = 13;
	a[0].Student_major = {"Computer"};
	a[0].Student_identity = { "common" };
	shouye();
	login();
	cout << "学生是否输入初始数据,是请输入1,不是请输入2"<<endl;
	cin >> kk;
	if (kk == 1) {
		cout << "请输入要输入的个数"<<endl;
		cin >> hh;
		Student_Count = hh + 1;
			hh = hh + 1;
		for (int ll = 1; ll < hh; ll++) {
			a[ll].Set_Date();
		}
	}
	cout << "老师是否输入初始数据,是请输入3,不是请输入4"<<endl;
	cin >> kk;
	if (kk ==3) {
		cout << "请输入要输入的个数"<<endl;
		cin >> hh;
		Teacher_Count = hh;
		for (int ll = 0; ll < hh; ll++) {
			b[ll].Set_Date();
		}
	}
	//Printf();
	int test = 1;
		while (1) {
			Printf();
			cin >> test;
			switch (test) {
			case 1:
				cout << "想添加学生的信息请输入a,想添加老师的信息请输入b" << endl;
				char pink;
				cin >> pink;
				if (pink == 'a') {
					Add_Date(Student_Count, p);
					Student_Count++;
					system("cls");
				}
				if (pink == 'b') {
					Add_Date(Teacher_Count, h);
					Teacher_Count++;
					system("cls");
				}
				break;
			case 2:
				cout << "如果你想删除学生的资料请输入c,如果你想删除老师的资料请输入d" << endl;
				char pink1;
				cin >> pink1;
				if (pink1 == 'c') {
					cout << "请输入你要删除的学生的学号" << endl;
					int k;
					cin >> k;
					Delt_Date(k, Student_Count, p);
					Student_Count = Student_Count - 1;
					p = a;
					getchar();
					system("cls");
				}
				if (pink1 == 'd') {
					cout << "请输入你要删除的老师的教工号" << endl;
					int k;
					cin >> k;
					Delt_Date(k, Teacher_Count, h);
					Teacher_Count = Teacher_Count - 1;
					h = b;
					getchar();
					system("cls");
				}
				break;
			case 3:
				cout << "如果你想要修改学生的成绩请输入e,如果你想修改老师的工资请输入f" << endl;
				char pink2;
				cin >> pink2;
				if (pink2 == 'e') {
					cout << "请输入你要修改的学生的学号" << endl;
					int k1;
					cin >> k1;
					Update_Date(k1, Student_Count, p);
					p = a;
					getchar();
					system("cls");
				}
				if (pink2 == 'f') {
					cout << "请输入你要修改老师的教工号" << endl;
					int k1;
					cin >> k1;
					Update_Date(k1, Teacher_Count, h);
					h = b;
					getchar();
					system("cls");
				}
				break;
			case 4:
				cout << "如果你想要寻找学生的请输入g,如果你想修改老师的工资请输入h" << endl;
				char pink3;
				cin >> pink3;
				if (pink3 == 'g') {
					Search_Date(p, Student_Count);
					system("pause");
					p = a;
				}
				if (pink3 == 'h') {
					Search_Date(h, Teacher_Count);
					system("pause"); 
					h = b;
				}
				break;
			case 5:
				cout << "如果你想要寻找学生请输入j,如果你想寻找老师输入k" << endl;
				char pink4;
				cin >> pink4;
				if (pink4 == 'j') {
					int k = 0;
					student* m;
					m = p;
					for (k; k < Student_Count; k++, p++) {
						if (m->English > (p + 1)->English) {

						}
						else { m = p + 1; }
					}
					if(Student_Count!=0){ m->FindMax_Date(); }
					else { cout << "没有数据"; }
					p = a;
					getchar();
					getchar();
				}
				if (pink4 == 'k') {
					teacher* l;
					int k = 0;
					h = b;
					l = b;
					for (k; k < Teacher_Count; k++, h++) {
						if (l->Teacher_salary>(h+1)->Teacher_salary ){
						}
						else {
							l = h + 1;
						}
					}
					if(Teacher_Count != 0) { l->FindMax_Date(); }
					else { cout << "没有数据"; }
					h = b;
					getchar();
					getchar();
				}
				break;
			case 6:
				Display(Student_Count, p);
				cout << endl;
				Display(Teacher_Count, h);
				getchar();
				getchar();
				p = a;
				h = b;
				break;
			case 7:
				Display(Student_Count,p);
				Student_duchu(Student_Count);
				Display(Teacher_Count, h);
				Teacher_duchu(Teacher_Count);
				getchar();
				getchar();
				p = a;
				h = b;
				break;
			case 8:
				mess(p);
				mess1(h);
				p = a;
				h = b;
				system("pause");
				break;
			case 9:
				rongqi();
				system("pause");
				break;
			case 10:
				zhuxiao();
				break;
			default:
					cout << "请输入正确数值" << endl;
				system("pause");
			}
	}
	return 0;
}


  • 6
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值