当前位置:
凯发ag旗舰厅登录网址下载 >
编程语言
> c/c
>内容正文
c/c
c 职工信息管理系统 -凯发ag旗舰厅登录网址下载
凯发ag旗舰厅登录网址下载
收集整理的这篇文章主要介绍了
c 职工信息管理系统
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
#include
#include
#include
#include
#include
#include
using namespace std;
int checkcin(int n)
{ if(cin.fail()){cin.clear();cin.sync();}cout<<"输入错误,请重新输入"<<endl; cin>>n;return n;
}
class w{public:int showmenu(){cout<<endl;system("date/t");system("time/t");cout<<endl;cout<<endl<<"\t\t\t\t\t欢迎使用职工管理系统"<<endl<<endl<<endl;cout<<"\t\t\t\t\t1.添加职工信息"<<endl<<endl; cout<<"\t\t\t\t\t2.浏览职工信息"<<endl<<endl;cout<<"\t\t\t\t\t3.删除职工信息"<<endl<<endl;cout<<"\t\t\t\t\t4.修改职工信息"<<endl<<endl;cout<<"\t\t\t\t\t5.查找职工信息"<<endl<<endl;cout<<"\t\t\t\t\t6.按照职工号(从小到大)进行排序"<<endl<<endl;cout<<"\t\t\t\t\t7.按照职工工资(从大到小)进行排序"<<endl<<endl;cout<<"\t\t\t\t\t8.职工号排序后按照职工号进行插入"<<endl<<endl; cout<<"\t\t\t\t\t9.对员工信息进行保存"<<endl<<endl;cout<<"\t\t\t\t\t0.退出程序"<<endl<<endl; }int showmenu1(){system("color 07");cout<<endl;system("date/t");system("time/t");cout<<endl;cout<<endl<<"\t\t\t\t\t欢迎使用职工管理系统"<<endl<<endl<<endl;cout<<"\t\t\t\t\t1.浏览职工信息"<<endl<<endl;cout<<"\t\t\t\t\t2.查找职工信息"<<endl<<endl;cout<<"\t\t\t\t\t3.按照职工号(从小到大)进行排序"<<endl<<endl;cout<<"\t\t\t\t\t4.按照职工工资(从大到小)进行排序"<<endl<<endl;cout<<"\t\t\t\t\t5.返回选择登录方式页面"<<endl<<endl; cout<<"\t\t\t\t\t0.退出程序"<<endl<<endl;} int exit1(){cout<<"欢迎下次使用"<<endl;system("pause");exit(0); }
};
class worker{public:int setnumber(int number_){this->number=number_;}int setname(string name_){this->name=name_;}int setsex(string sex_){this->sex=sex_;}int setbirthday(string birthday_){this->birthday=birthday_;}int setxl(string xl_){this->xl=xl_;}int setposition(string position_){this->position=position_;}int setmoney(int money_){this->money=money_;}int setadd(string add_){this->add=add_;}int settele(string tele_){this->tele=tele_;}int getnumber(){return this->number;}string getname(){return this->name;}string getsex(){return this->sex;}string getbirthday(){return this->birthday;}string getxl(){return this->xl;}string getposition(){return this->position;}int getmoney(){return this->money;}string getadd(){return this->add;}string gettele(){return this->tele;} worker* setnext(worker *p){this->next=p;}worker* getnext(){return this->next;}private:int number;string name;string sex;string birthday;string xl;string position;int money;string add;string tele;worker *next;
};
class functionwork:public worker{public:functionwork(){head=new worker();//建立头节点并将其初始化 head->setnext(null);}int add();//添加职工信息 int liulan();//浏览职工信息 int del();//删除职工信息 int xiugai();//修改职工信息 int chaxun();//查询职工信息 int keep();//保存职工信息 int read(); //读取职工信息 int numpaixu();//按照职工号进行排序 int monpaixu();//按照工资进行排序 int charu();//插入职工信息 private:worker *p1,*p2,*head;//建立头指针和备用指针
};
int functionwork::add()
{int number1;string name1;string sex1;string birthday1;string xl1;string position1;int money1;string add1;string tele1;p2=head;worker *p3;while(p2->getnext()){p2=p2->getnext();}int n;cout<<"请输入你想添加的职工数:";cin>>n;while(cin.fail())n=checkcin(n); for(int i=0;i<n;i ){int cntt=0;p1=new worker();p1->setnext(null);cout<<"请输入第"<<i 1<<"个职工信息"<<endl;while(1){ cout<<"请输入职工号:";cin>>number1;while(cin.fail())number1=checkcin(number1); p3=head->getnext();while(p3!=null){if(p3->getnumber()==number1){cout<<"职工号重复,请重新输入!";break;}p3=p3->getnext(); }if(p3==null){p1->setnumber(number1);break;}elsecontinue;}cout<<"请输入姓名:";cin>>name1;p1->setname(name1);while(1){if(cntt>0)cout<<"你输入性别有误!请重新输入"; cout<<"请输入性别:";cin>>sex1;if(sex1=="男")break;else if(sex1=="女")break;cntt ;} p1->setsex(sex1);cout<<"请输入出生年月:";cin>>birthday1;p1->setbirthday(birthday1);cout<<"请输入学历:";cin>>xl1;p1->setxl(xl1);cout<<"请输入职务:";cin>>position1;p1->setposition(position1);while(1){cout<<"请输入工资:";cin>>money1;if(cin.fail()){while(cin.fail())money1=checkcin(money1) ;} elsebreak;}p1->setmoney(money1);cout<<"请输入地址:";cin>>add1;p1->setadd(add1);cout<<"请输入电话:";cin>>tele1;p1->settele(tele1);system("cls");p2->setnext(p1);p2=p1;}cout<<"添加完毕!谢谢使用";system("pause");
}
int functionwork::liulan()
{if(head->getnext()==null){cout<<"您尚未添加任何职工信息!"<<endl;system("pause");return 0; }cout<<"职工号\t"<<"姓名\t"<<"性别\t"<<"出生年月 "<<"学历\t"<<"职务\t"<<"工资\t"<<"地址\t"<<"职工电话\t"<<endl; p1=head->getnext();while(p1!=null){cout<<p1->getnumber()<<"\t"<<p1->getname()<<"\t"<<p1->getsex()<<"\t"<<p1->getbirthday()<<" \t"<<p1->getxl()<<"\t"<<p1->getposition()<<"\t"<<p1->getmoney()<<"\t"<<p1->getadd()<<"\t"<<p1->gettele()<<endl;p1=p1->getnext(); }system("pause");return 0;
}
int functionwork::del()
{int a;int h=0;cout<<"请输入你想删除的职工号:" ;cin>>a;if(cin.fail()){ while(cin.fail())a=checkcin(a) ;} worker *p3; p3=head->getnext();while(p3!=null){if(p3->getnumber()==a){break; }p3=p3->getnext();}if(p3==null){cout<<"没有此职工!"<<endl; system("pause");system("cls");return 0;}else{cout<<"你想要删除职工号信息如下:"<<endl;cout<<"姓名:"<<p3->getname()<<endl<<"性别:"<<p3->getsex()<<endl<<"出生年月:"<<p3->getbirthday()<<endl<<"学历:"<<p3->getxl()<<endl<<"职务:"<<p3->getposition()<<endl<<"工资:"<<p3->getmoney()<<endl<<"地址:"<<p3->getadd()<<endl<<"电话:"<<p3->gettele()<<endl<<endl; string arr;while(1){cout<<"是否确认删除(是或否):";cin>>arr;if(arr=="是")break; else if(arr=="否"){cout<<"谢谢使用!"<<endl;system("pause");return 0; } else{cout<<"请输入是或否,其他无效!";system("pause"); continue; }}fstream fp;fp.open("删除职工统计",ios::app);fp<<"姓名:"<<p3->getname()<<endl<<"性别:"<<p3->getsex()<<endl<<"出生年月:"<<p3->getbirthday()<<endl<<"学历:"<<p3->getxl()<<endl<<"职务:"<<p3->getposition()<<endl<<"工资:"<<p3->getmoney()<<endl<<"地址:"<<p3->getadd()<<endl<<"电话:"<<p3->gettele()<<endl<<endl; worker *t; t=head;while(t->getnext()!=p3)t=t->getnext();t->setnext(p3->getnext());p3->setnext(null);cout<<"删除成功"<<endl; system("pause");system("cls");return 0;}
}
int functionwork::xiugai()
{string name1;string sex1;string birthday1;string xl1;string position1;int money1;string add1;string tele1;int o;cout<<"1.全部修改"<<endl<<"2.局部修改"<<endl;cout<<"请输入修改方式:";cin>>o;while(cin.fail())o=checkcin(o);if(o==1){while(1){int b; cout<<"请输入你想修改的职工号:";cin>>b;p1=head->getnext();while(p1!=null){if(p1->getnumber()==b)break;p1=p1->getnext();}if(p1==null){cout<<"没有找到你想修改的职工号!"<<endl;cout<<"1.继续输入"<<endl<<"(除1外任意键).返回主菜单";cout<<"请输入你的选择(1或者除1外任意键):"; getchar();char c; c=getchar();if(c=='1')continue; else return 0; }else{int cnttt=0;cout<<"请输入修改后的姓名:";cin>>name1;p1->setname(name1);while(1){if(cnttt>0)cout<<"性别输入格式错误";cout<<"请输入修改后的性别:";cin>>sex1;if(sex1=="男")break;if(sex1=="女")break; cnttt ; }p1->setsex(sex1);cout<<"请输入修改后的出生年月:";cin>>birthday1;p1->setbirthday(birthday1);cout<<"请输入修改后的学历:";cin>>xl1;p1->setxl(xl1);cout<<"请输入修改后的职务:";cin>>position1;p1->setposition(position1);while(1){cout<<"请输入修改后的工资:";cin>>money1;if(cin.fail()){while(cin.fail())money1=checkcin(money1);} elsebreak;}p1->setmoney(money1);cout<<"请输入修改后的地址:";cin>>add1;p1->setadd(add1);cout<<"请输入修改后的电话:";cin>>tele1;p1->settele(tele1);cout<<"修改成功!"<<endl;getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; getchar();char c;c=getchar();if(c=='1')continue;else return 0; }}}if(o==2){while(1){int b; cout<<"请输入你想修改的职工号:";cin>>b;p1=head->getnext();while(p1!=null){if(p1->getnumber()==b)break;p1=p1->getnext();}if(p1==null){cout<<"没有找到你想修改的职工号!"<<endl;cout<<"1.继续输入"<<endl<<"(除1外任意键).返回主菜单";cout<<"请输入你的选择(1或者除1外任意键):"; getchar();char c; c=getchar();if(c=='1')continue; else return 0; }else{while(1){cout<<"1.修改姓名"<<endl<<"2.修改性别"<<endl<<"3.修改出生年月"<<endl<<"4.修改学历"<<endl<<"5.修改职务"<<endl<<"6.修改工资"<<endl<<"7.修改地址"<<endl<<"8.修改电话号码"<<endl;cout<<"请输入你的选择:";int a; cin>>a;while(cin.fail())a=checkcin(a);if(a==1){cout<<"请输入修改后的姓名:";cin>>name1;p1->setname(name1);cout<<"修改成功!"<<endl;getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0; }if(a==2){cout<<"请输入修改后的性别:";cin>>sex1;p1->setsex(sex1);cout<<"修改成功!"<<endl;getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0;}if(a==3){cout<<"请输入修改后的出生年月:";cin>>birthday1;p1->setbirthday(birthday1);cout<<"修改成功!"<<endl;getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0;} if(a==4){cout<<"请输入修改后的学历:";cin>>xl1;p1->setxl(xl1);cout<<"修改成功!"<<endl;getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0;}if(a==5){cout<<"请输入修改后的职务:";cin>>position1;p1->setposition(position1);cout<<"修改成功!"<<endl;getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0;}if(a==6){cout<<"请输入修改后的工资:";cin>>money1;while(cin.fail())money1=checkcin(money1);p1->setmoney(money1);cout<<"修改成功!"<<endl;getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0;}if(a==7){cout<<"请输入修改后的地址:";cin>>add1;p1->setadd(add1);cout<<"修改成功!"<<endl;getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0; }if(a==8){cout<<"请输入修改后的电话:";cin>>tele1;p1->settele(tele1);cout<<"修改成功!"<<endl;getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0;}if(a>8){cout<<"没有此选项!";getchar();cout<<"1.继续修改"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0;} }}} }if(o>=2){cout<<"输入错误!"<<endl;cout<<"任意键返回主菜单!";system("pause");return 0; }
}
int functionwork::chaxun()
{int number1;string name1;string tele1;if(head->getnext()==null){cout<<"未读取到职工信息,请手动添加后再进行查询!"<<endl;system("pause");return 0;}while(1){cout<<"1.按照职工号查询"<<endl<<"2.按照姓名查询"<<endl<<"3.按照电话号码查询"<<endl;cout<<"请输入你的选择:"; int z;cin>>z;while(cin.fail())z=checkcin(z);if(z==1){cout<<"请输入你想要查询的工号:";cin>>number1; p1=head;while(p1!=null){if(p1->getnumber()==number1)break;p1=p1->getnext();}if(p1==null){getchar();cout<<"抱歉!没找到此职工"<<endl;cout<<"1.继续查询"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0;}else{cout<<"职工号:"<<p1->getnumber()<<endl<<"姓名:"<<p1->getname()<<endl<<"性别:"<<p1->getsex()<<endl<<"出生年月:"<<p1->getbirthday()<<endl<<"学历:"<<p1->getxl()<<"职务:"<<p1->getposition()<<endl<<"工资:"<<p1->getmoney()<<endl<<"地址:"<<p1->getadd()<<endl<<"电话:"<<p1->gettele()<<endl; system("pause");cout<<"感谢你的使用!";sleep(1000); return 0;} }if(z==2){int cnt=0;cout<<"请输入你想查找的姓名:";cin>>name1;p1=head;while(p1!=null){if(p1->getname()==name1){cout<<"职工号:"<<p1->getnumber()<<endl<<"姓名:"<<p1->getname()<<endl<<"性别:"<<p1->getsex()<<endl<<"出生年月:"<<p1->getbirthday()<<endl<<"学历:"<<p1->getxl()<<"职务:"<<p1->getposition()<<endl<<"工资:"<<p1->getmoney()<<endl<<"地址:"<<p1->getadd()<<endl<<"电话:"<<p1->gettele()<<endl; cout<<endl;cnt ;}p1=p1->getnext(); } system("pause");if(cnt==0){getchar();cout<<"抱歉!没找到此职工"<<endl;cout<<"1.继续查询"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0; }else if(cnt>0){getchar(); cout<<"我们已经为你找到相应职工!"<<endl;cout<<"1.继续查询"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0; } }if(z==3){cout<<"请输入你想查询的电话号码!";cin>>tele1;p1=head;while(p1!=null){if(p1->gettele()==tele1)break;p1=p1->getnext();}if(p1==null){getchar();cout<<"抱歉!没找到此职工"<<endl;cout<<"1.继续查询"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0;}else{cout<<"职工号:"<<p1->getnumber()<<endl<<"姓名:"<<p1->getname()<<endl<<"性别:"<<p1->getsex()<<endl<<"出生年月:"<<p1->getbirthday()<<endl<<"学历:"<<p1->getxl()<<"职务:"<<p1->getposition()<<endl<<"工资:"<<p1->getmoney()<<endl<<"地址:"<<p1->getadd()<<endl<<"电话:"<<p1->gettele()<<endl; system("pause");cout<<"感谢你的使用!";sleep(1000); return 0; }}if(z>3){getchar();cout<<"你的输入有误"<<endl;cout<<"1.继续查询"<<endl<<"(任意键).返回主菜单"<<endl;cout<<"请输入你的选择(1或者任意键):"; char c; c=getchar();if(c=='1')continue; else return 0; }}
}
int functionwork::keep()
{ofstream fp[2];int cnt=1;fp[0].open("职工信息管理1.txt",ios::out);fp[1].open("职工信息管理2.txt",ios::out);for(int i=0;i<2;i ){p1=head->getnext();while(p1!=null){if(i==0){fp[i]<<"第"<<cnt<<"名职工"<<endl<<"职工号:"<<p1->getnumber()<<endl<<"职工姓名:"<<p1->getname()<<endl<<"职工性别:"<<p1->getsex()<<endl<<"职工出生年月:"<<p1->getbirthday()<<endl<<"职工学历:"<<p1->getxl()<<endl<<"职工职位 "<<p1->getposition()<<endl<<"职工工资:"<<p1->getmoney()<<endl<<"职工地址:"<<p1->getadd()<<endl<<"职工电话:"<<p1->gettele()<<endl<<endl;p1=p1->getnext(); cnt ;}if(i==1){fp[i]<<p1->getnumber()<<" "<<p1->getname()<<" "<<p1->getsex()<<" "<<p1->getbirthday()<<" "<<p1->getxl()<<" "<<p1->getposition()<<" "<<p1->getmoney()<<" "<<p1->getadd()<<" "<<p1->gettele()<<" ";p1=p1->getnext();} } }cout<<"保存成功!";fp[0].close();fp[1].close(); system("pause");return 0;
}
int functionwork::read()
{int number1;string name1;string sex1;string birthday1;string xl1;string position1;int money1;string add1;string tele1;ifstream fp;fp.open("职工信息管理2.txt",ios::in);if(fp==null){cout<<"未读到职工信息,你可以手动添加";system("pause");return 0; }else{cout<<"读取成功,欢迎使用!";sleep(1000);}p2=head;int cnt=0; while(!fp.eof()) {p1=new worker();fp>>number1>>name1>>sex1>>birthday1>>xl1>>position1>>money1>>add1>>tele1;if(number1==p2->getnumber())break;p1->setnumber(number1);p1->setname(name1);p1->setsex(sex1);p1->setbirthday(birthday1);p1->setxl(xl1);p1->setposition(position1);p1->setmoney(money1);p1->setadd(add1);p1->settele(tele1);p2->setnext(p1);p1->setnext(null);p2=p1;cnt ;}fp.close();return 0;
}
int functionwork::numpaixu()
{int number1;string name1;string sex1;string birthday1;string xl1;string position1;int money1;string add1;string tele1;if(head->getnext()==null){cout<<"文件为空,无法进行排序"<<endl;system("pause");return 0; } for(p1=head->getnext();p1!=null;p1=p1->getnext()){for(p2=p1->getnext();p2!=null;p2=p2->getnext()){if(p1->getnumber()>p2->getnumber()){number1=p1->getnumber();name1=p1->getname();sex1=p1->getsex();birthday1=p1->getbirthday();xl1=p1->getxl();position1=p1->getposition();money1=p1->getmoney();add1=p1->getadd();tele1=p1->gettele();p1->setnumber(p2->getnumber());p1->setname(p2->getname());p1->setsex(p2->getsex());p1->setbirthday(p2->getbirthday());p1->setxl(p2->getxl());p1->setposition(p2->getposition());p1->setmoney(p2->getmoney());p1->setadd(p2->getadd());p1->settele(p2->getadd());p2->setnumber(number1);p2->setname(name1);p2->setsex(sex1);p2->setbirthday(birthday1);p2->setxl(xl1);p2->setposition(position1);p2->setmoney(money1);p2->setadd(add1);p2->settele(tele1);} }}cout<<"排序成功!";system("pause");return 0;
}
int functionwork::monpaixu()
{int number1;string name1;string sex1;string birthday1;string xl1;string position1;int money1;string add1;string tele1;if(head->getnext()==null){cout<<"文件为空,无法进行排序"<<endl;system("pause");return 0; } for(p1=head->getnext();p1!=null;p1=p1->getnext()){for(p2=p1->getnext();p2!=null;p2=p2->getnext()){if(p1->getmoney()<p2->getmoney()){number1=p1->getnumber();name1=p1->getname();sex1=p1->getsex();birthday1=p1->getbirthday();xl1=p1->getxl();position1=p1->getposition();money1=p1->getmoney();add1=p1->getadd();tele1=p1->gettele();p1->setnumber(p2->getnumber());p1->setname(p2->getname());p1->setsex(p2->getsex());p1->setbirthday(p2->getbirthday());p1->setxl(p2->getxl());p1->setposition(p2->getposition());p1->setmoney(p2->getmoney());p1->setadd(p2->getadd());p1->settele(p2->getadd());p2->setnumber(number1);p2->setname(name1);p2->setsex(sex1);p2->setbirthday(birthday1);p2->setxl(xl1);p2->setposition(position1);p2->setmoney(money1);p2->setadd(add1);p2->settele(tele1);} }}cout<<"排序成功!";system("pause");return 0;
}
int functionwork::charu()
{worker *a;int flag=0;a=head->getnext();if(a==null){cout<<"未读到任何职工信息,请添加后再插入"<<endl;system("pause");return 0;}else{for(a=head->getnext();a->getnext()!=null;a=a->getnext()){if(a->getnumber()>a->getnext()->getnumber())flag=1;}if(flag==1){cout<<"请按照职工号排完序后再插入!"<<endl;system("pause");return 0;}}int number1;string name1;string sex1;string birthday1;string xl1;string position1;int money1;string add1;string tele1;if(head->getnext()==null){cout<<"暂未从文件中读取任何职工信息不能插入!"<<endl;system("pause");return 0; } worker *p3,*q,*t;p2=head->getnext();q=head->getnext();t=head->getnext();p1=new worker();p1->setnext(null);cout<<"请输入插入职工的信息!"; while(1){ cout<<"请输入职工号:";cin>>number1;p3=head->getnext();while(p3!=null){if(p3->getnumber()==number1){cout<<"职工号重复,请重新输入!";break;}p3=p3->getnext(); }if(p3==null){p1->setnumber(number1);break;}elsecontinue;}cout<<"请输入姓名:";cin>>name1;p1->setname(name1);int cntt=0;while(1){if(cntt>0)cout<<"你输入性别有误!请重新输入"; cout<<"请输入性别:";cin>>sex1;if(sex1=="男")break;else if(sex1=="女")break;cntt ;} p1->setsex(sex1);cout<<"请输入出生年月:";cin>>birthday1;p1->setbirthday(birthday1);cout<<"请输入学历:";cin>>xl1;p1->setxl(xl1);cout<<"请输入职务:";cin>>position1;p1->setposition(position1);while(1){cout<<"请输入工资:";cin>>money1;if(!cin){cout<<"请正确输入工资格式!"; cin.clear();cin.sync();system("pause"); }elsebreak;} p1->setmoney(money1);cout<<"请输入地址:";cin>>add1;p1->setadd(add1);cout<<"请输入电话:";cin>>tele1;p1->settele(tele1);if(q->getnumber()>p1->getnumber()){head->setnext(p1);p1->setnext(q); cout<<"插入成功!";system("pause");return 0;}while(q->getnext()!=null)q=q->getnext();if(q->getnumber()<p1->getnumber()){q->setnext(p1);p1->setnext(null);cout<<"插入成功!";return 0;system("pause");} while(p2){if(p1->getnumber()<p2->getnumber()){while(t->getnext()!=p2)t=t->getnext();t->setnext(p1);p1->setnext(p2);cout<<"插入成功!";return 0;system("pause");}p2=p2->getnext(); }
}
typedef struct user
{char id[10];char mima[10];char namea[10];char sexa[10];long phone;
}use;
int creation()
{file *fp;if((fp=fopen("users.txt","rb"))==null){if((fp=fopen("users.txt","wb "))==null){cout<<"无法正常打开!"; exit(0); }}
}
int login()
{system("cls");file *p;use *a,*b;use c,d;a=&c,b=&d;int cnt=0;printf("\n\n\n\n\n\n\t***********(-^〇^-)************欢迎来到登录界面!***********(=^▽^=)****\n\n");p=fopen("users.txt","r");fread(b,sizeof(use),1,p);cout<<"请输入你的账号:"; cin>>a->id;while(1){if(strcmp(a->id,b->id)==0)break;else{if(feof(p)==0)fread(b,sizeof(use),1,p);else{cout<<"此用户不存在!";sleep(1000);fclose(p);return 0; }}}cout<<"请输入密码:"; char crr[20];int min=1;int max=10;int i;char ch;while(1)
{i = 0;while(1){ch = getch();if(ch == '\r')break;else if(ch == '\b'){if(i > 0){cout<<"\b \b";i--;}continue;}cout<<"*";if(i > max)break;crr[i ] = ch;}crr[i] = 0;if(i < min || i > max)cout<<endl<<"请再次输入:"; elsebreak;
}strcpy(a->mima,crr);while(1){if(strcmp(a->mima,b->mima)==0){cout<<endl<<"登录成功,欢迎使用!"<<endl; sleep(500);return 1; }else{cout<<endl<<"密码输入错误,请重新输入:"; while(1){i = 0;while(1){ch = getch();if(ch == '\r')break;else if(ch == '\b'){if(i > 0){cout<<"\b \b";i--;}continue;}cout<<"*";if(i > max)break;crr[i ] = ch;}crr[i] = 0;if(i < min || i > max)cout<<"请再次输入:";elsebreak;}strcpy(a->mima,crr);cnt ;if(cnt==2&&strcmp(a->mima,b->mima)!=0){cout<<"抱歉!你已经三次输入密码错误!我们将返回主菜单!"<<endl;sleep(2000); cnt=0;return 0;}}}
}
int registers()
{system("cls");use *a,*b;use c,d;a=&c,b=&d;file *p;char arr[20];printf("\n\n\n\n\n\n\t***********(-^〇^-)************欢迎来到注册界面!***********(=^▽^=)****\n\n");sleep(1000);p=fopen("users.txt","r");fread(b,sizeof(use),1,p);cout<<"请输入账号:";cin>>a->id;while(1){if(strcmp(a->id,b->id)!=0){if(feof(p)==0){fread(b,sizeof(use),1,p);}elsebreak;}else{cout<<"此用户名已存在!请重新注册!"<<endl; sleep(1000);fclose(p);return 0; }} cout<<"请输入姓名:";cin>>a->namea;while(1){cout<<"请输入性别:";cin>>a->sexa;if(strcmp("男",a->sexa)==0)break;if(strcmp("女",a->sexa)==0)break; }for(int i=0;i<2;i )a->sexa[i]=arr[i];cout<<"请输入手机号:";cin>>a->phone;cout<<"请输入密码:";cin>>a->mima;cout<<"请确认密码:";cin>>arr;while(1){if(strcmp(a->mima,arr)==0){p = fopen("users.txt","a");fwrite(a, sizeof(use), 1, p);cout<<"账号注册成功,请登录!"<<endl; sleep(1000);fclose(p);return 0;}else{cout<<"两次输入密码不匹配!请重新输入:";cin>>a->mima ;cout<<"请再次确认密码:";cin>>arr;}}
}
int seekl()
{system("cls");use *a,*b;file *p;use c,d;a=&c,b=&d;int cnt=0;char arr[20];cout<<endl<<endl<<endl<<endl<<endl<<endl<<"\t***********(-^〇^-)************欢迎来到找回密码界面!***********(=^▽^=)****"<<endl<<endl;sleep(1000);p=fopen("users.txt","r");fread(b,sizeof(use),1,p);cout<<"请输入账户:";cin>>a->id;while(1){if(strcmp(a->id,b->id)==0){break;}else{if(feof(p)==0){fread(b,sizeof(use),1,p);}else{cout<<"此用户名不存在,请重新输入!"<<endl;sleep(500); fclose(p); return 0; }}}cout<<"请输入你的姓名:"; cin>>a->namea;while(1){if(strcmp(a->namea,b->namea)==0){break;}else{cout<<"你输入的姓名有误!请重新输入:";cnt ;cin>>a->namea;if(cnt==2&&strcmp(a->namea,b->namea)!=0){cout<<"抱歉你已经三次输入错误,我们将返回主菜单!"<<endl;sleep(3000);cnt=0;return 0;}}}cnt=0; cout<<"请输入你的电话号码:";cin>>a->phone; while(1){if((a->phone==b->phone)){break;}else{cout<<"你输入的号码有误,请重新输入:";cnt ;cin>>a->phone;if(cnt==2&&(a->phone!=b->phone));{cout<<"你已经两次输入错误,再见!"<<endl;sleep(3000);cnt=0;return 0;} }} cout<<"你的密码是:";cout<<b->mima;cout<<"我们已经找回你的密码谢谢使用!"; sleep(1000);
}
int main()
{while(1){system("cls");int hh;cout<<"\n\n\n\n\n\t\t\t1.管理员登录"<<endl;cout<<"\t\t\t2.普通用户查看"<<endl; cout<<"请选择登陆方式:";cin>>hh;while(cin.fail())hh=checkcin(hh); if(hh==1){ creation();int c,flag=0;while(1){system("cls");cout<<"\n\n\n\n\n\t\t\t欢迎来到管理员登陆系统!\n";cout<<"\n\n\n\n\t\t\t********************1.登录账号";cout<<"\n\n\n\n\t\t\t********************2.注册账号";cout<<"\n\n\n\n\t\t\t********************3.找回密码\n";cout<<"\t\t\t请输入你想要进行的操作:"; cin>>c;if(cin.fail()){while(cin.fail())c=checkcin(c) ;} else{switch(c){case 1:flag=login();system("pause");break;case 2:registers();break;case 3:seekl();break;}if(flag==1)break;}}w h;functionwork a; a.read();system("cls");int choice;while(1){h.showmenu();cout<<"请选择你想要进行的操作:";cin>>choice;while(cin.fail())choice=checkcin(choice);switch(choice){case 1:system("cls");a.add();a.keep();system("cls");system("pause");break;case 2:system("cls");a.liulan();system("cls");break;case 3:system("cls");a.del();system("cls");break;case 4:system("cls");a.xiugai();system("cls");break;case 5:system("cls");a.chaxun();system("cls");break;case 6:system("cls");a.numpaixu();system("cls");break;case 7:system("cls");a.monpaixu();system("cls");break;case 8:system("cls");a.charu();system("cls"); break;case 9:system("cls");a.keep();system("cls") ;break;case 0:system("cls"); h.exit1();break;default:if(choice>9)cout<<"没有你想进行的操作!"<<endl;system("pause");break; }}
}if(hh==2)
{w h;functionwork a; a.read();system("cls");int choice;while(1){h.showmenu1();cout<<"请选择你想要进行的操作:";cin>>choice;while(cin.fail())choice=checkcin(choice);switch(choice){case 1:system("cls");a.liulan();system("cls");break;case 2:system("cls");a.chaxun();system("cls");break;case 3:system("cls");a.numpaixu();system("cls");break;case 4:system("cls");a.monpaixu();system("cls");break;case 5:system("cls");main();system;system("cls");break; case 0:system("cls"); h.exit1();break;default:if(choice>4)cout<<"没有你想进行的操作!"<<endl;system("pause");break; }}} else{cout<<"输入错误,请重新输入"<<endl;continue;}
}
}
总结
以上是凯发ag旗舰厅登录网址下载为你收集整理的c 职工信息管理系统的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。
- 上一篇: echarts地图初体验
- 下一篇: 关于静态联编和动态联编