当前位置:   article > 正文

c++ 学生管理系统(包含登录--管理员-教师-学生三种登录)_c++登录注册管理员管理系统

c++登录注册管理员管理系统

//包含五个.h文件

fream_name.h//包含文件宏定义

#pragma once
#define FILENAME1 "student.txt"
#define FILENAME2 "account.txt"
  • 1
  • 2
  • 3

all.h//包含全部头文件

#pragma once
#include<iostream>
#include<fstream>
#include<conio.h>
#include<string>
using namespace std;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

account.h//账号类定义

#pragma once
#include"all.h"
#include"fream_name.h"
class Account
{
public:
	Account(int ,string,int );
	void display();
	int account;//账号
	string password;//密码
	int id;//身份
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

student.h//学生类定义

#pragma once
#include"all.h"
#include"fream_name.h"
class Student
{
public:
	Student(int ,string ,string,string, int ,int );
	void display();
	int num;//学号
	string name;//姓名
	string grade;//年级
	string sex;//性别
	int age;//年龄
	int number;//电话号码
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

people.h//总的部分定义(包含各种操作)

#pragma once
#include"student.h"
#include"account.h"
class People_Manager
{
public:
	People_Manager();

	int Stu_Num;//学生人数
	Student **M_Student;//学生数组指针

	void stu_init();//初始化
	int stu_num();//初始化数量

	int Acc_Num;//账户人数
	Account **M_Account;//账户数组指针

	void acc_init();//初始化
	int acc_num();//初始化数量


	void account_save();//账户保存
	void stu_add();//添加学生
	void stu_sort();//排序学生
	void stu_del();//删除学生
	void stu_mod();//修改学生
	void stu_find();//查找学生
	void stu_save();//保存学生
	void stu_show();//显示学生
	void stu_oper();//学生操作
	void tea_oper();//教师操作
	void man_oper();//管理员操作
	int pass_au(string&);//密码验证  
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

//四个.cpp文件

account.cpp//对账户的部分操作

#include"account.h"
Account::Account(int m_account, string m_password,int m_id)
{
	account = m_account;
	password = m_password;
	id = m_id;
}
void Account::display()
{
	if (id == 1)
	{
		cout << "\t学生学号:" << account << endl;
		cout << "\t密码:" << password << endl;
	}
	else
		if (id == 2)
		{
			cout << "\t教师职工号:" << account << endl;
			cout << "\t密码:" << password << endl;
		}
		else
			if (id == 3)
			{
				cout << "\t管理员账号:" << account << endl;
				cout << "\t密码:" << password << endl;
			}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

//student.cpp 部分学生类的操作

#include"student.h"

Student::Student(int m_num, string m_name, string m_grade, string m_sex, int m_age, int m_number)
{
	this->num = m_num;
	this->name = m_name;
	this->grade = m_grade;
	this->sex = m_sex;
	this->age = m_age;
	this->number = m_number;
}

void Student::display()
{
	cout << "学号:" << this->num << endl;
	cout << "姓名:" << this->name << endl;
	cout << "年级:" << this->grade << endl;
	cout << "性别:" << this->sex << endl;
	cout << "年龄:" << this->age << endl;
	cout << "电话号码:" << this->number << endl;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

people.cpp//所有操作集中

#include"people.h"

People_Manager::People_Manager()
{
	fstream f;
	f.open(FILENAME1, ios::in);
	if (!f.is_open())
	{
		cout << "文件不存在" << endl;
		Stu_Num=0;//学生人数
		M_Student=NULL;//数组指针
		f.close();
		return;
	}
	char ch;
	f >> ch; 
	if (f.eof() && f.is_open())
	{
		cout << "文件存在但是为空" << endl;
		Stu_Num = 0;//学生人数
		M_Student = NULL;//数组指针
		f.close();
		return;
	}
	Stu_Num = stu_num();
	M_Student = new Student*[Stu_Num];//开辟空间
	stu_init();
	f.close();
	ifstream ifo;
	ifo.open(FILENAME2, ios::in);
	if (!ifo.is_open())
	{
		cout << "文件不存在" << endl;
		Acc_Num = 0;//学生人数
		M_Account = NULL;//数组指针
		f.close();
		return;
	}
	f >> ch;
	if (f.eof() && f.is_open())
	{
		cout << "文件存在但是为空" << endl;
		Acc_Num = 0;//学生人数
		M_Account = NULL;//数组指针
		f.close();
		return;
	}
	Acc_Num = acc_num();
	M_Account = new Account*[Acc_Num];//开辟空间
	acc_init();
	ifo.close();
}

void People_Manager::stu_init()//初始化
{
	fstream f;
	f.open(FILENAME1, ios::in);
	int m_num;
	string m_name;
	string m_grade;
	string m_sex;
	int m_age;
	int m_number;

	int  i = 0;
	//读取
	while (f >> m_num&&f >> m_name&&f >> m_grade&&f >> m_sex&&f >> m_age&&f >> m_number)
	{
		Student *stu = NULL;
		stu = new Student(m_num, m_name, m_grade, m_sex, m_age, m_number);
		M_Student[i] = stu;
		i++;
	}
	f.close();
}

int People_Manager::stu_num()//初始化数量
{
	fstream f;
	f.open(FILENAME1, ios::in);
	int i = 0;
	int m_num;
	string m_name;
	string m_grade;
	string m_sex;
	int m_age;
	int m_number;
	while (f >> m_num&&f >> m_name&&f >> m_grade&&f >> m_sex&&f >> m_age&&f >> m_number)
	{
		i++;
	}
	f.close();
	return i;
}

void People_Manager::acc_init()//账户初始化
{
	fstream f;
	f.open(FILENAME2 ,ios::in);
	int account;
	string password;
	int id;
	int  i = 0;
	while (f >> account&&f >> password&&f>>id)
	{
		Account *Acc = NULL;
		Acc = new Account(account, password, id);
		M_Account[i] = Acc;
		i++;
	}
	f.close();
}

void People_Manager::stu_show()//显示学生
{
	for (int i = 0; i < Stu_Num; i++)
	{
		M_Student[i]->display();
	}
	system("pause");
	system("cls");
}

void People_Manager::stu_add()//添加学生
{
	fstream f;
	f.open(FILENAME2, ios::out);
	if (!f.is_open())
	{
		cout << "文件不存在" << endl;
		return;
	}
	int j;
	int num;
	cout << "请输入要添加学生的数量:" << endl;
	cin >> num;
	Account **Acc_Manager = new Account*[Acc_Num+num];
	int i;
	for ( i = 0; i < Acc_Num; i++)
	{
		Acc_Manager[i] = M_Account[i];
	}
	j = i;
	int account;
	string password;
	//新建一个更大空间的数组
	Student **E_Student;
	E_Student = new Student *[Stu_Num + num];
	//复制数组
	for ( i = 0; i < Stu_Num; i++)
	{
		E_Student[i] = M_Student[i];
	}
	int id;
	int m_num;
	string m_name;
	string m_grade;
	string m_sex;
	int m_age;
	int m_number;
	
	for (i=0; i < num; i++)
	{
		int flag = 0;
		Account *acc = NULL;
		Student *stu = NULL;
		cout << "请输入第" << i+ 1 << "个学生的学号:" << endl;
		cin >> m_num;
		//判断是否存在重复
		for (int jjj = 0; jjj < Stu_Num; jjj++)
		{
			if (M_Student[jjj]->num == m_num)
			{
				cout << "已有该同学,请重新输入..." << endl;
				system("pause");
				system("cls");
				flag = 1;
				i--;
				break;
			}
		}
		if (flag == 1)
		{
			continue;
		}
		cout << "请输入第" << i  + 1 << "个学生的姓名:" << endl;
		cin >> m_name;
		cout << "请输入第" << i  + 1 << "个学生的年纪:" << endl;
		cin >> m_grade;
		cout << "请输入第" << i  + 1 << "个学生的性别:" << endl;
		cin >> m_sex;
		cout << "请输入第" << i  + 1 << "个学生的年龄:" << endl;
		cin >> m_age;
		cout << "请输入第" << i + 1 << "个学生的电话号码:" << endl;
		cin >> m_number;
		//默认密码为666666
		acc = new Account(m_num, "666666",1);
		Acc_Manager[j] = acc;
		stu=new Student(m_num, m_name, m_grade, m_sex, m_age, m_number);
		E_Student[i+ Stu_Num] = stu;
		j++;
	}
	//释放之前所开辟的空间
	delete[] M_Student;
	delete[] M_Account;

	M_Account = Acc_Manager;
	M_Student = E_Student;
	//数量加
	Stu_Num += num; 
	Acc_Num += num;

	cout << "成功添加" << num << "位学生" << endl;

	f.close();

	stu_save();	
	account_save();

	system("pause");
	system("cls");
}

void People_Manager::stu_save()//保存学生
{
	fstream f;
	f.open(FILENAME1, ios::out);
	for (int i = 0; i < Stu_Num; i++)
	{
		f << M_Student[i]->num << " "
			<< M_Student[i]->name << " "
			<< M_Student[i]->grade << " "
			<< M_Student[i]->sex << " "
			<< M_Student[i]->age << " "
			<< M_Student[i]->number << endl;
	}
	f.close();
}

void People_Manager::stu_del()//删除学生
{
	int num;
	string name;
	int id;
	cout << "输入删除的学生学号和姓名" << endl;
	cin >> num;
	cin >> name;
	for (int i = 0; i < Stu_Num; i++)
	{
		if (M_Student[i]->num == num && M_Student[i]->name==name)
		{
			for (int j = i; j < Stu_Num; j++)
			{
				M_Student[j] = M_Student[j+1];
			}
			cout << "删除成功" << endl;

			Stu_Num--;

			break;
		}
	}
	for (int k = 0; k < Acc_Num; k++)
	{
		if (M_Account[k]->account == num)
		{
			for (int j = k; j < Acc_Num; j++)
			{
				M_Account[k] = M_Account[k + 1];
			}
		}
	}
	//数量减一
	Acc_Num--;
	stu_save();
	account_save();
	system("pause");
	system("cls");
}

void People_Manager::stu_mod()//修改学生
{
	int num;
	string name;
	int id;
	int j;
	int i = 0;
	cout << "输入修改的学生学号和姓名" << endl;
	cin >> num;
	cin >> name;
	for (; i < Stu_Num; i++)
	{
		if (M_Student[i]->num == num && M_Student[i]->name== name)
		{
			j = i;
			break;
		}
	}
	if (i == Stu_Num)
	{
		cout << "查无此人" << endl;
		return;
	}
	int k;	
	int m_num;
	string m_name;
	string m_grade;
	string m_sex;
	int m_age;
	int m_number;	
	while (true)
	{
		int ch;
		cout << "1、学号" << endl;
		cout << "2、姓名" << endl;
		cout << "3、年级" << endl;
		cout << "4、性别" << endl;
		cout << "5、年龄" << endl;
		cout << "6、电话号码" << endl;
		cout << "7、所有" << endl;
		cout << "0、返回" << endl;
		cout << "请输入要修改的部分:" << endl;

		cin >> ch;

		switch (ch)
		{
		case 1:
			cout << "输入新学号:" << endl;
			for (int i = 0; i < Acc_Num; i++)
			{
				if (M_Account[i]->account == m_num)
				{
					k = i;
					break;
				}
			}
			cin >> m_num;
			M_Student[j]->num = m_num;
			M_Account[k]->account = m_num;
			cout << "修改成功" << endl;
			system("pause");
			system("cls");
			break;
		case 2:
			cout << "输入新姓名:" << endl;
			cin >> m_name;
			M_Student[j]->name = m_name;
			cout << "修改成功" << endl;
			system("pause");
			system("cls");
			break;
		case 3:
			cout << "输入新年级:" << endl;
			cin >> m_grade;
			M_Student[j]->grade = m_grade;
			cout << "修改成功" << endl;
			system("pause");
			system("cls");
			break;
		case 4:
			cout << "输入新性别:" << endl;
			cin >> m_sex;
			M_Student[j]->sex = m_sex;
			cout << "修改成功" << endl;
			system("pause");
			system("cls");
			break;
		case 5:
			cout << "输入新年龄:" << endl;
			cin >> m_age;
			M_Student[j]->age = m_age;
			cout << "修改成功" << endl;
			system("pause");
			system("cls");
			break;
		case 6:
			cout << "输入新电话号码:" << endl;
			cin >> m_number;
			M_Student[j]->number = m_number;
			cout << "修改成功" << endl;
			system("pause");
			system("cls");
			break;
		case 7:
			for (int i = 0; i < Acc_Num; i++)
			{
				if (M_Account[i]->account == m_num)
				{
					k = i;
					break;
				}
			}
			cout << "输入新学号:" << endl;
			cin >> m_num;
			M_Student[j]->num = m_num;
			M_Account[k]->account = m_num;
			cout << "输入新姓名:" << endl;
			cin >> m_name;
			M_Student[j]->name = m_name;
			cout << "输入新年级:" << endl;
			cin >> m_grade;
			M_Student[j]->grade = m_grade;
			cout << "输入新性别:" << endl;
			cin >> m_sex;
			M_Student[j]->sex = m_sex;
			cout << "输入新年龄:" << endl;
			cin >> m_age;
			M_Student[j]->age = m_age;
			cout << "输入新电话号码:" << endl;
			cin >> m_number;
			M_Student[j]->number = m_number;
			cout << "修改成功" << endl;
			system("pause");
			system("cls");
			break;
		case 0:
			system("cls");
			stu_save();
			return;
			break;
		}
	}
		
}

void People_Manager::stu_find()//查找学生
{
	
	int num;
	string name;
	int j,i;
	cout << "输入查找的学生学号和姓名" << endl;
	cin >> num;
	cin >> name;
	for ( i = 0; i < Stu_Num; i++)
	{
		if (M_Student[i]->num == num && M_Student[i]->name==name)
		{
			j = i;
		cout << M_Student[j]->num << " "<<
		M_Student[j]->name << " " <<
		M_Student[j]->grade << " " <<
		M_Student[j]->sex << " " <<
		M_Student[j]->age << " " <<
		M_Student[j]->number << endl;
			break;
		}
	}
	if (i == Stu_Num)
	{
		cout << "查无此人" << endl;
	}
	system("pause");
	system("cls");

}

void  People_Manager::stu_oper()//操作
{
	int account;
	string password;
	while (true)
	{
		cout << "输入学号:" << endl;
		cin >> account;
		cout << "输入密码:" << endl;
		pass_au(password);
		int flag = 0;
		int j;
		char b;
		for (int k = 0; k < Acc_Num; k++)
		{
			if (M_Account[k]->account == account&&M_Account[k]->password == password&&M_Account[k]->id==1)
			{
				flag = 1;	
				j = k;
				cout << "登录成功" << endl;
				system("pause");
				system("cls");
				break;
			}
		}
		if (flag)
		{
			int c;
			while (true)
			{
				cout << "\t\t-----------------" << endl;
				cout << "\t\t|1、查看自身信息|" << endl;
				cout << "\t\t-----------------" << endl;
				cout << "\t\t|2、 修改密码   |" << endl;
				cout << "\t\t-----------------" << endl;
				cout << "\t\t|0、    返回    |" << endl;
				cout << "\t\t-----------------" << endl;
				cin >> c;
				switch (c)
				{
				case 1:
					for (int k = 0; k < Stu_Num; k++)
					{
						if (M_Student[k]->num == account)
						{
							M_Student[k]->display();
							system("pause");
							system("cls");
							break;
						}
					}
					break;
				case 2:
					cout << "输入新密码:" << endl;
					cin >> password;
					M_Account[j]->password = password;
					account_save();
					cout << "修改成功" << endl;
					system("pause");
					system("cls");
					break;
				case 0:
					system("cls");
					return;
					break;
				}
			}
		}
		else
		{
			cout << "密码错误" << endl;
			cout << "是否重新输入....(y/n)" << endl;
			cin >> b;
			if (b == 'n')
			{
				system("cls");
				return;
			}
			system("cls");
		}
	}
}

void People_Manager::tea_oper()//教师操作
{
	int account;
	string password;
	while (true)
	{
		cout << "输入职工号:" << endl;
		cin >> account;
		cout << "输入密码:" << endl;
		//cin >> password;
		int flag = 0;
		pass_au(password);
		int j;
		for (int k = 0; k < Acc_Num; k++)
		{
			if (M_Account[k]->id==2&&M_Account[k]->account == account&&M_Account[k] ->password == password)
			{
				flag = 1;
				j = k;
				cout << "登录成功" << endl;
				system("pause");
				system("cls");
				break;
			}
		}
		if (flag)
		{
			int c;
			while (true)
			{
				cout << "\t\t----------------------" << endl;
				cout << "\t\t|1、查看所有学生信息|" << endl;
				cout << "\t\t----------------------" << endl;
				cout << "\t\t|2、查看单个学生信息|" << endl;
				cout << "\t\t----------------------" << endl;
				cout << "\t\t|3、    修改密码    | " << endl;
				cout << "\t\t----------------------" << endl;
				cout << "\t\t|0、    返回        |" << endl;
				cout << "\t\t----------------------" << endl;
				cin >> c;
				int flag2 = 0;
				switch (c)
				{
				case 1:
					for (int k = 0; k < Stu_Num; k++)
					{
						M_Student[k]->display();						
					}
					system("pause");
					system("cls");
					break;
				case 2:
					
					cout << "输入学生的学号:" << endl;
					cin >> account;
					for (int k = 0; k < Stu_Num; k++)
					{
						if (M_Student[k]->num == account)
						{
							flag2=1;
							M_Student[k]->display();
							system("pause");
							system("cls");
							break;
						}
					}
					if (!flag2)
					{
						cout << "查无此人" << endl;
					}
					break;
				case 3:
					cout << "输入新密码:" << endl;
					cin >> password;
					M_Account[j]->password = password;
					account_save();
					break;
				case 0:
					system("cls");
					return;
					break;
				}
				system("cls");
			}
		}
		else
		{
			char b;
			cout << "密码错误" << endl;
			cout << "是否重新输入....(y/n)" << endl;
			cin >> b;
			if (b == 'n')
			{
				system("cls");
				return;
			}
			system("cls");
		}
	}
}

void  People_Manager::account_save()//账户保存
{
	fstream f;
	f.open(FILENAME2, ios::out);
	if (!f.is_open())
	{
		cout << "文件不存在" << endl;
		return;
	}
	for (int i = 0; i < Acc_Num; i++) {
		f << M_Account[i]->account << " " <<
			M_Account[i]->password <<" " <<
			M_Account[i]->id<<" "<<endl;
	}
	f.close();
}

void People_Manager::man_oper()//管理员操作
{

	int number = 3;
	int ACCOUNT;
	string PASSWORD;
	string password;
	int id;
	int account;
	while (true)
	{

		if (number == 3)
		{
			cout << "请输入账号:" << endl;
			cin >> ACCOUNT;
		}
		cout << "请输入密码:" << endl;
		pass_au(PASSWORD);
		int FLAG = 0;
		for (int ii = 0; ii < Acc_Num; ii++)
		{
			if (M_Account[ii]->account == ACCOUNT&&M_Account[ii]->id == 3 && M_Account[ii]->password==PASSWORD)
			{
				FLAG = 1;
				break;
			}
		}
		if (FLAG)
		{
			cout << "登录成功...." << endl;
			system("pause");
			system("cls");
			//
			int ch;
			int f;
			while (true)
			{
				
				int flag = 0;
				cout << "\t\t --------------------" << endl;
				cout << "\t\t|1、学生信息的操作  |" << endl;
				cout << "\t\t --------------------" << endl;
				cout << "\t\t|2、   账号操作     |" << endl;
				cout << "\t\t --------------------" << endl;
				cout << "\t\t|0、   退出登录     |" << endl;
				cout << "\t\t --------------------" << endl;
				cout << "输入你的选择:" << endl;
				cin >> ch;
				system("cls");
				switch (ch)
				{
				case 1:
					//
					while (true)
					{
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|1、 增添学生   |" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|2、 删除学生   |" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|3、修改学生信息|" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|4、  查找学生  |" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|5、显示学生信息|" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|6、排序学生    |" << endl;
						cout << "\t\t  ---------------" << endl;
						cout << "\t\t|0、  返回      |" << endl;
						cout << "\t\t  ---------------" << endl;
						cout << "输入你的选择:" << endl;
						cin >> ch;
						switch (ch)
						{
						case 1:
							stu_add();
							break;
						case 2:
							stu_del();
							break;
						case 3:
							stu_mod();
							break;
						case 4:
							stu_find();
							break;
						case 5:
							stu_show();
							break;
						case 6:
							stu_sort();
							break;
						case 0:
							flag = 1;
							break;

						}
						if (flag)
						{
							break;//退出循环
						}
					}
					system("cls");
					//
					break;
				case 2:
					//
					int as;

					while (true)
					{
						Account **Acc_M = new Account*[Acc_Num + 1];
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|1、添加教师账号|" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|2、删除教师账号|" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|3、查看所有账号|" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|4、修改密码    |" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "\t\t|0、退出        |" << endl;
						cout << "\t\t-----------------" << endl;
						cout << "输入你的选择:" << endl;
						cin >> ch;
						switch (ch)
						{
						case 1:
							while (true)
							{
								f = 0;
								
								cout << "输入教师的职工号:" << endl;
								cin >> account;
								for (int iii = 0; iii < Stu_Num; iii++)
								{
									if (M_Account[iii]->account == account&&M_Account[iii]->id==2)
									{
										cout << "该教师已经存在,请重新输入..." << endl;
										f = 1;
										break;
									}
								}
								if (!f)
								{
									break;
								}
							}
							for (int xi=0; xi < Acc_Num; xi++)
							{
								Acc_M[xi] = M_Account[xi];
							}
							Account *acc_m;
							acc_m = new Account(account, "111111", 2);
							Acc_M[Acc_Num] = acc_m;
							delete[]M_Account;
							M_Account = Acc_M;
							Acc_Num++;
							account_save();
							cout << "添加成功.." << endl;
							system("pause");
							system("cls");
							break;
						case 2:
							cout << "输入教师的职工号:" << endl;
							cin >> account;
							for (int ii = 0; ii < Acc_Num; ii++)
							{
								if (M_Account[ii]->account == account&&M_Account[ii]->id==2)
								{
									for (int jj = ii; jj < Acc_Num; jj++)
									{
										M_Account[jj] = M_Account[jj + 1];
									}
									break;
								}
							}
							Acc_Num--;
							account_save();
							cout << "删除成功.." << endl;
							system("pause");
							system("cls");
							break;
						case 3:
							for (int i = 0; i < Acc_Num; i++)
							{
								M_Account[i]->display();
							}
							system("pause");
							system("cls");
							break;
						case 4:
							for (int ii = 0; ii < Acc_Num; ii++)
							{
								if (M_Account[ii]->account == ACCOUNT&&M_Account[ii]->id == 3)
								{
									cout << "输入修改后的密码:" << endl;
									cin >> password;
									M_Account[ii]->password = password;
									break;
								}
							}
							account_save();
							cout << "修改成功.." << endl;
							system("pause");
							system("cls");
							break;
						case 0:
							flag = 1;
							break;
						}
						if (flag)
						{
							system("cls");
							break;
						}
					}
					system("cls");
					//
					break;
				case 0:
					system("cls");
					return;
					break;
				}
			}
			//
			return;
			
		}
		else
		{
			char  c;
			number--;
			cout << "共有三次,还剩" << number << "次";
			cout << "密码错误,是否重新输入. . .(y/n) " << endl;
			cin >> c;
			if (number == 0) {
				cout << "密码错误,进行锁定。" << endl;
				cout << "无法再次输入密码" << endl;
				_getch();
				system("cls");
				break;
			}
			//cout << "共有三次,还剩" << number << "次";	
			system("pause");
			if (c == 'n')
			{
				system("cls");
				return;
			}
			system("cls");
			
		}
	}
}

void People_Manager::stu_sort()//排序学生
{
	while (true)
	{
		system("cls");
		cout << "\t\t----------------" << endl;
		cout << "\t\t|1、顺序排序|" << endl;
		cout << "\t\t----------------" << endl;
		cout << "\t\t|2、逆序排序|" << endl;
		cout << "\t\t----------------" << endl;
		cout << "\t\t|0、  返回  |" << endl;
		cout << "\t\t----------------" << endl;
		cout << "输入你的选择:" << endl;
		int c;
		cin >> c;

		switch (c)
		{
		case 1:
			for (int i = 0; i < Stu_Num; i++)
			{
				for (int j = 0; j < Stu_Num - i - 1; j++)
				{
					if (M_Student[j]->num > M_Student[j + 1]->num)
					{
						swap(M_Student[j], M_Student[j + 1]);
					}
				}
			}
			cout << "排序成功" << endl;
			system("pause");
			system("cls");
			break;
		case 2:
			for (int i = 0; i < Stu_Num; i++)
			{
				for (int j = 0; j < Stu_Num - i - 1; j++)
				{
					if (M_Student[j]->num < M_Student[j + 1]->num)
					{
						swap(M_Student[j], M_Student[j + 1]);
					}
				}
			}
			cout << "排序成功" << endl;
			system("pause");
			system("cls");
			break;
		case 0:
			system("cls");
			stu_save();
			return;
			break;
		}

	}

}

int People_Manager::acc_num()//初始化数量
{
	fstream f;
	f.open(FILENAME2, ios::in);
	int i = 0;
	int account;
	string password;
	int id;
	while (f >> account && f >> password&&f >> id)
	{
		i++;
	}
	f.close();
	return i;
}

int People_Manager::pass_au(string &pass)//密码验证
{
	char password[1024];
	int index = 0;
	while (1) {
		char ch;
		ch = _getch();
		if (ch == 8) {
			if (index > 0) {
				index--;
				cout << char(8) << " " << char(8);
				
			}
		}
		else
			if (ch == '\r') {
				password[index] = '\0';
				cout << endl;
				break;
			}
			else
			{
				cout << "*";
				password[index++] = ch;
			}
	}
	for (int i = 0; i < index; i++) {
		pass += password[i];
	}

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604
  • 605
  • 606
  • 607
  • 608
  • 609
  • 610
  • 611
  • 612
  • 613
  • 614
  • 615
  • 616
  • 617
  • 618
  • 619
  • 620
  • 621
  • 622
  • 623
  • 624
  • 625
  • 626
  • 627
  • 628
  • 629
  • 630
  • 631
  • 632
  • 633
  • 634
  • 635
  • 636
  • 637
  • 638
  • 639
  • 640
  • 641
  • 642
  • 643
  • 644
  • 645
  • 646
  • 647
  • 648
  • 649
  • 650
  • 651
  • 652
  • 653
  • 654
  • 655
  • 656
  • 657
  • 658
  • 659
  • 660
  • 661
  • 662
  • 663
  • 664
  • 665
  • 666
  • 667
  • 668
  • 669
  • 670
  • 671
  • 672
  • 673
  • 674
  • 675
  • 676
  • 677
  • 678
  • 679
  • 680
  • 681
  • 682
  • 683
  • 684
  • 685
  • 686
  • 687
  • 688
  • 689
  • 690
  • 691
  • 692
  • 693
  • 694
  • 695
  • 696
  • 697
  • 698
  • 699
  • 700
  • 701
  • 702
  • 703
  • 704
  • 705
  • 706
  • 707
  • 708
  • 709
  • 710
  • 711
  • 712
  • 713
  • 714
  • 715
  • 716
  • 717
  • 718
  • 719
  • 720
  • 721
  • 722
  • 723
  • 724
  • 725
  • 726
  • 727
  • 728
  • 729
  • 730
  • 731
  • 732
  • 733
  • 734
  • 735
  • 736
  • 737
  • 738
  • 739
  • 740
  • 741
  • 742
  • 743
  • 744
  • 745
  • 746
  • 747
  • 748
  • 749
  • 750
  • 751
  • 752
  • 753
  • 754
  • 755
  • 756
  • 757
  • 758
  • 759
  • 760
  • 761
  • 762
  • 763
  • 764
  • 765
  • 766
  • 767
  • 768
  • 769
  • 770
  • 771
  • 772
  • 773
  • 774
  • 775
  • 776
  • 777
  • 778
  • 779
  • 780
  • 781
  • 782
  • 783
  • 784
  • 785
  • 786
  • 787
  • 788
  • 789
  • 790
  • 791
  • 792
  • 793
  • 794
  • 795
  • 796
  • 797
  • 798
  • 799
  • 800
  • 801
  • 802
  • 803
  • 804
  • 805
  • 806
  • 807
  • 808
  • 809
  • 810
  • 811
  • 812
  • 813
  • 814
  • 815
  • 816
  • 817
  • 818
  • 819
  • 820
  • 821
  • 822
  • 823
  • 824
  • 825
  • 826
  • 827
  • 828
  • 829
  • 830
  • 831
  • 832
  • 833
  • 834
  • 835
  • 836
  • 837
  • 838
  • 839
  • 840
  • 841
  • 842
  • 843
  • 844
  • 845
  • 846
  • 847
  • 848
  • 849
  • 850
  • 851
  • 852
  • 853
  • 854
  • 855
  • 856
  • 857
  • 858
  • 859
  • 860
  • 861
  • 862
  • 863
  • 864
  • 865
  • 866
  • 867
  • 868
  • 869
  • 870
  • 871
  • 872
  • 873
  • 874
  • 875
  • 876
  • 877
  • 878
  • 879
  • 880
  • 881
  • 882
  • 883
  • 884
  • 885
  • 886
  • 887
  • 888
  • 889
  • 890
  • 891
  • 892
  • 893
  • 894
  • 895
  • 896
  • 897
  • 898
  • 899
  • 900
  • 901
  • 902
  • 903
  • 904
  • 905
  • 906
  • 907
  • 908
  • 909
  • 910
  • 911
  • 912
  • 913
  • 914
  • 915
  • 916
  • 917
  • 918
  • 919
  • 920
  • 921
  • 922
  • 923
  • 924
  • 925
  • 926
  • 927
  • 928
  • 929
  • 930
  • 931
  • 932
  • 933
  • 934
  • 935
  • 936
  • 937
  • 938
  • 939
  • 940
  • 941
  • 942
  • 943
  • 944
  • 945
  • 946
  • 947
  • 948
  • 949
  • 950
  • 951
  • 952
  • 953
  • 954
  • 955
  • 956
  • 957
  • 958
  • 959
  • 960
  • 961
  • 962
  • 963
  • 964
  • 965
  • 966
  • 967
  • 968
  • 969
  • 970
  • 971
  • 972
  • 973
  • 974
  • 975
  • 976
  • 977
  • 978
  • 979
  • 980
  • 981
  • 982
  • 983
  • 984
  • 985
  • 986
  • 987
  • 988
  • 989
  • 990
  • 991
  • 992
  • 993
  • 994
  • 995
  • 996
  • 997
  • 998
  • 999
  • 1000
  • 1001
  • 1002
  • 1003
  • 1004
  • 1005
  • 1006
  • 1007
  • 1008
  • 1009
  • 1010
  • 1011
  • 1012
  • 1013
  • 1014
  • 1015
  • 1016
  • 1017
  • 1018
  • 1019
  • 1020
  • 1021
  • 1022
  • 1023

main.cpp//汇总操作

#include"all.h"
#include"fream_name.h"
#include"people.h"
#include<iostream>
#include<Windows.h>
using namespace std;
//可局部颜色变化
void color(unsigned short color_index)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color_index);
}

void menu()
{
	color(6);
	cout << "\t\t-------------------------" << endl;
	cout << "\t\t|                       |" << endl;;
	cout << "\t\t|   《1、学生登录 》    |" << endl;
	cout << "\t\t|                       |" << endl;;
	cout << "\t\t|   《2、教师登录 》    |" << endl;
	cout << "\t\t|                       |" << endl;;
	cout << "\t\t|   《3、管理员登录 》  |" << endl;
	cout << "\t\t|                       |" << endl;;
	cout << "\t\t|   《0、退出系统  》   |" << endl;
	cout << "\t\t|                       |" << endl;;
	cout << "\t\t-------------------------" << endl;
	cout << "请输入你的选择:" << endl;
}

int main() 
{
	People_Manager peo;	
	int  ch;
	while (true) 
	{
		menu();
		cin >> ch;
		switch (ch)
		{
		case 1:
			peo.stu_oper();//学生
			break;
		case 2:
			peo.tea_oper();//教师
			break;
		case 3:
			peo.man_oper();//管理员
			break;
		case 0:
			system("cls");
			cout << "\n\n\n\t欢迎下次使用" << endl << endl;
			system("pause");
			exit(0);
			break;
		default:
			cout << "无此选项" << ",";
			cout << "请重新输入...." << endl;
			system("pause");
			system("cls");
			break;
		}
	}
	_getch();
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号