日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

C++职工信息管理系统

發布時間:2024/10/14 c/c++ 130 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C++职工信息管理系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include<iostream> #include<string> #include<windows.h> #include<fstream> #include<conio.h> #include<cstring> 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;} } }

總結

以上是生活随笔為你收集整理的C++职工信息管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。