亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

用C++實現員工管理系統

2019-11-14 10:23:38
字體:
來源:轉載
供稿:網友
職工信息管理系統:1. 存在一個數據文件,用來存儲職工各種信息:職工號,姓名,年齡,性別,郵編,部門,工資2. 可以注冊新職工;3. 允許修改職工信息4. 允許刪除職工信息;5,按照按照姓名和部門查詢職工信息;6. 可以按照工資多少進行排名,7. 可以瀏覽所有職工信息;8.有一個主界面,供選擇和調用上述選項。

9.用C++中,文件和鏈表實現

#include <iostream>#include <string>#include <fstream>using namespace std;class staff{PRivate:string employee_number;//職工號string name;//姓名int age;//年齡string sex;//性別string zip_code;//郵編string department;//部門int wage;//工資class staff* next;public:staff():next(NULL){}void registration(class staff* head);//注冊 尾插void query_name(class staff* t);//按照姓名查詢員工信息void query_depart(class staff* t);//按照部門查詢員工信息void delete_num(class staff* t);//按工號刪除員工信息void delete_name(class staff* t);//按姓名刪除員工信息void show_all(class staff* head);//展示所有員工信息void update(class staff* head);void update_num(class staff* head);//修改工號void update_name(class staff* head);//修改姓名void update_age(class staff* head);//修改年齡void update_sex(class staff* head);//修改性別void update_zip(class staff* head);//修改郵編void update_depart(class staff* head);//修改部門void update_wage(class staff* head);//修改工資void update_all(class staff* head);//修改全部void sort_up(class staff* head);//按工資升序排列void sort_down(class staff* head);//按工資降序排列int read(class staff* head);void write(class staff* t);};void staff::registration(class staff* head){while(head->next != NULL){head = head->next;}staff* newnode = new staff;head->next = newnode;newnode->next = NULL;cout << "請輸入員工信息" << endl;cout << "職工號: " << endl;cin >> newnode->employee_number;cout << "職工姓名: " << endl;cin >> newnode->name;cout << "職工年齡: " << endl;cin >> newnode->age;cout << "職工性別: " << endl;cin >> newnode->sex;cout << "職工郵編: " << endl;cin >> newnode->zip_code;cout << "職工部門: " << endl;cin >> newnode->department;cout << "職工工資: " << endl;cin >> newnode->wage;}void staff::show_all(class staff* head){int i = 0;while(head->next != NULL){i++;cout << i << "." << "工號:" ;cout << head->next->employee_number <<'/t';cout << "名字:";cout << head->next->name <<'/t';cout << "性別:" ;cout << head->next->sex <<'/t';cout << "年齡:" ;cout <<  head->next->age <<'/t';cout << "郵編:" ;cout << head->next->zip_code << '/t';cout << "部門:";cout << head->next->department << '/t';cout << "工資:" ;cout << head->next->wage << endl;head = head->next;}}void staff::query_name(class staff* t){string n;cout << "請輸入你想查詢職工姓名:" << endl;cin >> n;int count = 0;while(t->next != NULL){if(t->next->name == n){cout << "工號:" ;cout << t->next->employee_number <<'/t';cout << "名字:";cout << t->next->name <<'/t';cout << "性別:" ;cout << t->next->sex <<'/t';cout << "年齡:" ;cout <<  t->next->age <<'/t';cout << "郵編:" ;cout << t->next->zip_code << '/t';cout << "部門:";cout << t->next->department << '/t';cout << "工資:" ;cout << t->next->wage << endl;count++;}t = t->next;}if(count == 0){cout << "查無此人!" << endl;}}void staff::query_depart(class staff* t){string n;cout << "請輸入你想查詢職工部門:" << endl;cin >> n;int count = 0;while(t->next != NULL){if(t->next->department == n){cout << "工號:" ;cout << t->next->employee_number <<'/t';cout << "名字:";cout << t->next->name <<'/t';cout << "性別:" ;cout << t->next->sex <<'/t';cout << "年齡:" ;cout <<  t->next->age <<'/t';cout << "郵編:" ;cout << t->next->zip_code << '/t';cout << "部門:";cout << t->next->department << '/t';cout << "工資:" ;cout << t->next->wage << endl;count++;}t = t->next;}if(count == 0){cout << "查無此人!" << endl;}}void staff::delete_num(class staff* t){string n;cout << "請輸入你想刪除職工號:" << endl;cin >> n;int count = 0;while(t->next != NULL){if(t->next->employee_number == n){staff* temp = t->next;t->next = t->next->next;delete temp;temp = NULL;cout << "刪除成功!" << endl;count++;break;}t = t->next;}if(count == 0){cout << "查無此人!" << endl;}}void staff::delete_name(class staff* t){string n;cout << "請輸入你想刪除職工的姓名:" << endl;cin >> n;int count = 0;while(t->next != NULL){if(t->next->name == n){staff* temp = t->next;t->next = t->next->next;delete temp;temp = NULL;cout << "刪除成功!" << endl;count++;break;}t = t->next;}if(count == 0){cout << "查無此人!" << endl;}}void staff::update(class staff* head){int num = 0;cout << "1.修改員工號" << endl;cout << "2.修改員工姓名" << endl;cout << "3.修改員工年齡" << endl;cout << "4.修改員工性別" << endl;cout << "5.修改員工郵編" << endl;cout << "6.修改員工部門" << endl;cout << "7.修改員工工資" << endl;cout << "8.修改全部" << endl;cin >> num;switch(num){case 1:update_num(head);break;case 2:update_name(head);break;case 3:update_age(head);break;case 4:update_sex(head);break;case 5:update_zip(head);break;case 6:update_depart(head);break;case 7:update_wage(head);break;case 8:update_all(head);break;default:cout << "請重新輸入正確的指令!" << endl;}}void staff::update_num(class staff* head){cout << "輸入要修改對象的工號:"<< endl;int count = 0;string temp;cin >> temp;while(head->next != NULL){if(temp == head->next->employee_number){count = 1;cout<< "輸入新工號:"<< endl;string temp2;cin>>temp2;head->next->employee_number = temp2;cout << "修改成功" << endl;break;}head = head->next;}if(count == 0){cout << "查無此人" << endl;}}void staff::update_name(class staff* head){cout << "輸入要修改對象的工號:"<< endl;int count = 0;string temp;cin >> temp;while(head->next != NULL){if(temp == head->next->employee_number){count = 1;cout << "輸入新名字:"<< endl;string temp2;cin >> temp2;head->next->name = temp2;cout << "修改成功" << endl;break;}head = head->next;}if(count == 0){cout << "查無此人" << endl;}}void staff::update_age(class staff* head){cout << "輸入要修改對象的工號:"<< endl;int count = 0;string temp;cin >> temp;while(head->next != NULL){if(temp == head->next->employee_number){count = 1;cout << "輸入新年齡:"<< endl;int temp2;cin >> temp2;head->next->age = temp2;cout << "修改成功" << endl;break;}head = head->next;}if(count == 0){cout << "查無此人" << endl;}}void staff::update_sex(class staff* head){cout << "輸入要修改對象的工號:"<< endl;int count = 0;string temp;cin >> temp;while(head->next != NULL){if(temp == head->next->employee_number){count = 1;cout << "輸入新性別:"<< endl;string temp2;cin >> temp2;head->next->sex = temp2;cout << "修改成功" << endl;break;}head = head->next;}if(count == 0){cout << "查無此人" << endl;}}void staff::update_zip(class staff* head){cout << "輸入要修改對象的工號:"<< endl;int count = 0;string temp;cin >> temp;while(head->next != NULL){if(temp == head->next->employee_number){count = 1;cout << "輸入新郵編:"<< endl;string temp2;cin >> temp2;head->next->zip_code = temp2;cout << "修改成功" << endl;break;}head = head->next;}if(count == 0){cout << "查無此人" << endl;}}void staff::update_depart(class staff* head){cout << "輸入要修改對象的工號:"<< endl;int count = 0;string temp;cin >> temp;while(head->next != NULL){if(temp == head->next->employee_number){count = 1;cout << "輸入新部門:"<< endl;string temp2;cin >> temp2;head->next->department = temp2;cout << "修改成功" << endl;break;}head = head->next;}if(count == 0){cout << "查無此人" << endl;}}void staff::update_wage(class staff* head){cout << "輸入要修改對象的工號:"<< endl;int count = 0;string temp;cin >> temp;while(head->next != NULL){if(temp == head->next->employee_number){count = 1;cout << "輸入新工資:"<< endl;int temp2;cin >> temp2;head->next->wage = temp2;cout << "修改成功" << endl;break;}head = head->next;}if(count == 0){cout << "查無此人" << endl;}}void staff::update_all(class staff* head){cout<<"輸入要修改對象的工號:"<<flush;int count = 0;string tmp;cin >> tmp;while(head->next != NULL){if(tmp == head->next->employee_number){count = 1;cout << "輸入新工號:"<< endl;string temp;int tmp;cin >> temp;head->next->employee_number = temp;cout<< "輸入新名字:"<< endl;cin >> temp;head->next->name = temp;cout<< "輸入新性別:"<< endl;cin >> temp;head->next->sex = temp;cout<< "輸入新年齡:"<< endl;cin >> tmp;head->next->age = tmp;cout<< "輸入新郵編:"<< endl;cin >> temp;head->next->zip_code = temp;cout<< "輸入新部門:"<< endl;cin >> temp;head->next->department = temp;cout<< "輸入新工資:"<< endl;cin >> tmp;head->next->wage = tmp;cout << "修改成功" << endl;break;}head = head->next;}if(count == 0){cout << "查無此人" << endl;}}void staff::sort_up(class staff* head){while(head->next != NULL){class staff* temp = head;while(temp->next != NULL){if(head->next->wage > temp->next->wage){int a;string b;a = head->next->wage;head->next->wage = temp->next->wage;temp->next->wage = a;b = head->next->employee_number;head->next->employee_number = temp->next->employee_number;temp->next->employee_number = b;b = head->next->name;head->next->name = temp->next->name;temp->next->name = b;b = head->next->sex;head->next->sex = temp->next->sex;temp->next->sex = b;a = head->next->age;head->next->age = temp->next->age;temp->next->age = a;b = head->next->zip_code;head->next->zip_code = temp->next->zip_code;temp->next->zip_code = b;b = head->next->department;head->next->department = temp->next->department;temp->next->department = b;}temp = temp->next;}head = head->next;}}void staff::sort_down(class staff* head){while(head->next != NULL){class staff* temp = head;while(temp->next != NULL){if(head->next->wage < temp->next->wage){int a;string b;a = head->next->wage;head->next->wage = temp->next->wage;temp->next->wage = a;b = head->next->employee_number;head->next->employee_number = temp->next->employee_number;temp->next->employee_number = b;b = head->next->name;head->next->name = temp->next->name;temp->next->name = b;b = head->next->sex;head->next->sex = temp->next->sex;temp->next->sex = b;a = head->next->age;head->next->age = temp->next->age;temp->next->age = a;b = head->next->zip_code;head->next->zip_code = temp->next->zip_code;temp->next->zip_code = b;b = head->next->department;head->next->department = temp->next->department;temp->next->department = b;}temp = temp->next;}head = head->next;}}int staff::read(class staff* head){ofstream infile1;infile1.open("職工系統.txt",ios::app);if(!infile1){return 0;}else{infile1.close();ifstream infile;infile.open("職工系統.txt",ios::in);while(!infile.eof()){staff* newnode = new staff;infile >> newnode->employee_number;if(newnode->employee_number.length() == 0){delete newnode;break;}infile >> newnode->name;infile >> newnode->sex;infile >> newnode->age;infile >> newnode->zip_code;infile >> newnode->department;infile >> newnode->wage;head->next = newnode;head = head->next;}infile.close();}return 0;}void staff::write(class staff* t){ofstream outfile;outfile.open("職工系統.txt",ios::out);while(t->next != NULL){outfile << t->next->employee_number <<'/t';outfile << t->next->name << '/t';outfile << t->next->sex << '/t';outfile << t->next->age << '/t';outfile << t->next->zip_code << '/t';outfile << t->next->department << '/t';outfile << t->next->wage << endl;t = t->next;}outfile.close();}int main(){staff* head = new staff;head->read(head);string temp;cout << "歡迎來到Coder職工系統!" << endl;while(1){cout << "------------------------------------" << endl;head->show_all(head);cout << "------------------------------------" << endl;cout << endl;cout << "1.注冊員工信息" << endl;cout << "2.按照姓名查詢員工信息" << endl;cout << "3.按照部門查詢員工信息" << endl;cout << "4.按工號刪除員工信息" << endl;cout << "5.按姓名刪除員工信息" << endl;cout << "6.按工資升序排列" << endl;cout << "7.按工資降序排列" << endl;cout << "8.修改員工信息" << endl;cout << "0.退出" << endl;cout << endl;cout << "請輸入你想選擇的功能:" << endl;int number;cin >> number;switch(number){case 1:{head->registration(head);break;}case 2:{head->query_name(head);break;}case 3:{head->query_depart(head);break;}case 4 :{head->delete_num(head);break;}case 5:{head->delete_name(head);break;}case 6:{head->sort_up(head);break;}case 7:{head->sort_down(head);break;}case 8:{head->update(head);break;}case 0:{head->write(head);return 0;}default: cout << "請重新輸入正確的操作指令" << endl;}}}


上一篇:簡單工廠模式

下一篇:0009 封裝

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日韩精品高清在线| 国产精品电影在线观看| 欧美激情按摩在线| 亚洲男人的天堂在线播放| 日韩电影在线观看永久视频免费网站| 日韩视频在线免费观看| 91精品国产91久久久久福利| 8090理伦午夜在线电影| 91网在线免费观看| 欧美日韩在线视频一区二区| 国产91在线播放九色快色| 欧美亚洲国产日韩2020| 欧美韩日一区二区| 亚洲成人精品久久| 亚洲第一页中文字幕| 欧美综合在线第二页| 色婷婷亚洲mv天堂mv在影片| 亚洲精品日韩av| 日韩av最新在线观看| 久久精视频免费在线久久完整在线看| 亚洲2020天天堂在线观看| 国产精品久久久久久久久久小说| 久久精品男人天堂| 色一区av在线| 欧洲亚洲妇女av| 国内精品免费午夜毛片| 久久久久久69| 欧美综合一区第一页| 亚洲精品综合久久中文字幕| 国产午夜精品免费一区二区三区| 国产精品一久久香蕉国产线看观看| 日韩国产在线看| 最近2019好看的中文字幕免费| 在线观看久久久久久| 久久久视频免费观看| 国产午夜精品美女视频明星a级| 亚洲精品www久久久| 91在线观看欧美日韩| 欧美专区第一页| 日韩女优人人人人射在线视频| 欧美与黑人午夜性猛交久久久| 国产成人自拍视频在线观看| 欧美一级bbbbb性bbbb喷潮片| 亚洲欧美激情视频| 久久精品99久久久久久久久| 亚洲 日韩 国产第一| 成人激情电影一区二区| 国产精品96久久久久久| 96精品视频在线| 国产亚洲成av人片在线观看桃| 国产一区二区丝袜高跟鞋图片| 色综合91久久精品中文字幕| 久久久精品视频在线观看| 久久香蕉精品香蕉| 亚洲电影免费观看高清完整版在线| 久久久亚洲网站| 亚洲午夜色婷婷在线| 91在线视频九色| 51久久精品夜色国产麻豆| 精品福利免费观看| 欧美日韩国产精品| 精品中文字幕在线观看| 国产亚洲美女精品久久久| 亚洲理论在线a中文字幕| 日韩中文字幕久久| 97在线视频免费看| 欧美日本高清视频| 欧美激情精品久久久久久变态| 亚洲最大福利网站| 亚洲国产成人久久综合一区| 国产激情综合五月久久| 欧美一区视频在线| 亚洲福利视频在线| 欧美裸体视频网站| 国产精选久久久久久| 日韩av电影免费观看高清| 国产中文字幕日韩| 欧美寡妇偷汉性猛交| 欧美激情videoshd| 国产午夜一区二区| 久久免费精品日本久久中文字幕| 亚洲人精选亚洲人成在线| 欧美激情在线播放| 日本一区二区三区在线播放| 日韩美女视频免费看| 亚洲人成五月天| 日韩视频永久免费观看| 色视频www在线播放国产成人| 91日韩在线视频| 国产成人在线亚洲欧美| 午夜精品久久久久久久男人的天堂| 亚洲性av在线| 国产拍精品一二三| 日韩av资源在线播放| 青青草99啪国产免费| 久久久国产视频91| 午夜伦理精品一区| 日韩精品亚洲元码| 欧美激情视频一区二区三区不卡| 国产精品户外野外| 成年人精品视频| 在线播放精品一区二区三区| 91高清免费视频| 国产成人精品视频在线观看| 永久免费精品影视网站| 日韩亚洲欧美中文在线| 中文日韩电影网站| 国产精品视频白浆免费视频| 久久伊人免费视频| 亚洲欧洲日本专区| 欧美精品videofree1080p| 亚洲精品成a人在线观看| 国产不卡视频在线| 精品国产91久久久久久老师| 久久国产精品偷| 亚洲人成在线免费观看| 欧美午夜精品久久久久久浪潮| 久久久久久久av| 俺去亚洲欧洲欧美日韩| 亚洲视频一区二区三区| 欧美精品在线极品| 国产一区二区视频在线观看| 2021久久精品国产99国产精品| 色中色综合影院手机版在线观看| 人人澡人人澡人人看欧美| 欧美壮男野外gaytube| 国产一区二区三区精品久久久| 国产精品久久久久久久久久免费| 色综合伊人色综合网站| 欧美精品在线视频观看| 91成品人片a无限观看| 亚洲性猛交xxxxwww| 亚洲成人亚洲激情| 亚洲香蕉av在线一区二区三区| 色婷婷综合久久久久| 九九热99久久久国产盗摄| 国产精品第3页| 久久久久久久999| 亚洲欧美日韩网| 久久精品色欧美aⅴ一区二区| 欧美视频不卡中文| 亚洲男人天堂网| 精品一区电影国产| 亚洲一区二区三区四区视频| 欧美寡妇偷汉性猛交| 91在线视频精品| 亚洲天堂av电影| 亚洲va码欧洲m码| 欧美国产极速在线| 亚洲精品wwwww| 亚洲成年网站在线观看| 亚洲成人久久久| 日韩中文字幕网址| 久热在线中文字幕色999舞| 久久999免费视频| 亚洲视频网站在线观看| 亚洲国产黄色片| 国产精品一区二区久久久久| 国产亚洲精品久久久久动| 欧美一级电影免费在线观看| 隔壁老王国产在线精品| 欧美日韩在线免费观看| 亚洲免费av网址| 亚洲国产精品99|