经过一段时间的学习,又有了新的收获刚好有同学找到了我,让我帮他写一个类似与学生管理系统一样的东西,经验有限,所以,不足之处请多多指正,欢迎评论。下面就先贴上源码了。
#include<iostream>
#include<string>
#include<algorithm>
#include<conio.h>
#include<fstream>
#include<set>
#include<cstring>
using namespace std;
struct user
{
string ID; //身份证
set<string> tel; //手机号
string name; //用户名
string sex; //性别
int age; // 年龄
string phe; //职业
string place; //家庭住址
user *nextuser;
};
class SInfo
{
user *userListHead;
public:
SInfo();
~SInfo();
void creat(); //新增用户
user *userFindtel(string tel); //电话查询
user *userFindID(string ID); //身份证查询
int checktel(string tel, user *p); //电话查询
int checktel(string tel); //重载
user *userFindname(string name); //用户名查询
void telin(string ID); // 注册手机号
void telout(string tel); // 注销手机号
void userModify(string name); //修改用户信息
void userDelete(string name); //删除用户信息
void userCopy(user *ptemp, user *p); //用户信息拷贝
void usernameSort(); //用户名排序
void userageSort(); //年龄排序
void userIDSort(); //身份证排序
void userinsert(string ID,string tel,string name,string sex,int age,string phe,string plac); //插入用户信息
void userRead(); //从文件读入学生信息
void userSave(); //保存用户信息到文件
void userQuit(); //安全退出
void ShowInfo(); //输出用户信息
};
//登陆界面
int Systemdoor()
{
string username = "jiangtao", password = "111111";
string name, temp;
int number = 3;
while (1)
{
cout << " 用户名:";
cin >> name;
cout << " 密码:";
cin >> temp;
if (name != username || temp != password)
{
number--;
if (number >0)
{
cout << " 用户名/密码错误你还有" << number << "次机会" << endl;
}
else
cout << "用户名/密码错误" << endl, exit(0);
}
else
{
cout << "********************密码正确********************" << endl<<endl;
return 1;
}
}
}
void ShowMenu()
{
cout << "********************************************" << endl;
cout << "****** 移 动 营 业 厅 ******" << endl;
cout << "****** 0.安全退出系统 ******" << endl;
cout << "****** 1.文件读取用户信息: ******" << endl;
cout << "****** 2.录入新的用户信息 ******" << endl;
cout << "****** 3.新增用户信息 ******" << endl;
cout << "****** 4.查询用户信息 ******" << endl;
cout << "****** 4.1.电话号码查询 ******" << endl;
cout << "****** 4.2.身份证查询 ******" << endl;
cout << "****** 4.3.用户名查询 ******" << endl;
cout << "****** 5.注册手机号 ******" << endl;
cout << "****** 6.注销手机号 ******" << endl;
cout << "****** 7.修改用户信息 ******" << endl;
cout << "****** 8.删除用户信息 ******" << endl;
cout << "****** 9.输出现有用户信息 ******" << endl;
cout << "****** 9.1.按用户名排序 ******" << endl;
cout << "****** 9.2.按身份证排序 ******" << endl;
cout << "****** 9.3.按年龄排序 ******" << endl;
cout << "\n\t\n\t\t请选择:&