【源码】员工管理系统c++大型实验,含实验报告
staff.h
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #pragma once 2 #include <iostream> 3 #include <string> 4 using namespace std; 5 class staff 6 { 7 public: 8 staff * next; 9 staff(void); 10 ~staff(void); 11 staff(int Num,string Name,int Age,int Edu,string Nation,string Major, int Post, int Partment,int Position); 12 void setAll(int Num,string Name,int Age,int Edu,string Nation,string Major, int Post, int Partment,int Position); 13 void setName(string s); 14 void setNum(int i); 15 void setAge(int i); 16 void setEdu(int i); 17 void setNation(string s); 18 void setMajor(string s); 19 void setPost(int i); 20 void setPartment(int i); 21 void setPosition(int i); 22 string getName(); 23 int getNum(); 24 int getAge(); 25 int getEdu(); 26 string getNation(); 27 string getMajor(); 28 int getPost(); 29 int getPartment(); 30 int getPosition(); 31 void display(); 32 private: 33 string name,nation,major; 34 int num,age,post,position,partment,edu; 35 36 };
staff.cpp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include "StdAfx.h" 2 #include "staff.h" 3 #include "iomanip" 4 #include"string" 5 #include<iostream> 6 using namespace std; 7 8 staff::staff(void) 9 { 10 name="小李"; 11 nation="汉"; 12 major="计算机"; 13 num=20142681; 14 age=20; 15 edu=1; 16 post=2; 17 position=3; 18 partment=4; 19 next = NULL; 20 21 } 22 23 staff::staff(int Num,string Name,int Age,int Edu,string Nation,string Major, int Post, int Partment,int Position) 24 { 25 name=Name; 26 nation=Nation; 27 major=Major; 28 num=Num; 29 age=Age; 30 edu=Edu; 31 post=Post; 32 partment=Partment; 33 position=Position; 34 next = NULL; 35 36 37 } 38 void staff::display() 39 { 40 string s_edu[] = { "小学", "初中", "高中", "本科", "硕士", "博士", "教授" }; 41 string s_post[] = { "助理工程师", "工程师", "高级工程师", "教授级高级工程师" }; 42 string s_partment[] = { "人事部", "技术部", "后勤部", "信息部" }; 43 string s_position[] = { "普通员工", "工程师 ", "团队领导", "部门领导", "公司领导" }; 44 cout << setiosflags(ios::left); 45 cout <<setw(10)<< num <<setw(10)<< name << setw(6)<< age <<setw(6) << s_edu[edu] <<setw(6)<< nation << 46 setw(10)<< major << setw(20)<< s_post[post] <<setw(8)<< s_partment[partment] <<setw(10) << s_position[position] << endl; 47 } 48 staff::~staff(void) 49 { 50 } 51 void staff::setAll(int Num,string Name,int Age,int Edu,string Nation,string Major, int Post, int Partment,int Position) 52 { 53 name=Name; 54 nation=Nation; 55 major=Major; 56 num=Num; 57 age=Age; 58 edu=Edu; 59 post=Post; 60 partment=Partment; 61 position=Position; 62 63 } 64 void staff::setName(string s) 65 { 66 name=s; 67 } 68 void staff::setNum(int i) 69 { 70 num =i; 71 72 } 73 74 void staff::setAge(int i) 75 { 76 age =i; 77 } 78 void staff::setEdu(int i) 79 { 80 edu=i; 81 } 82 void staff::setNation(string s) 83 { 84 nation =s; 85 } 86 void staff::setMajor(string s) 87 { 88 major=s; 89 } 90 void staff::setPost(int i) 91 { 92 post=i; 93 } 94 void staff::setPartment(int i) 95 { 96 partment=i; 97 } 98 void staff::setPosition(int i) 99 { 100 position=i; 101 } 102 string staff::getName() 103 { 104 return name; 105 } 106 int staff::getNum() 107 { 108 return num; 109 } 110 int staff::getAge() 111 { 112 return age; 113 } 114 int staff::getEdu() 115 { 116 return edu; 117 } 118 string staff::getNation() 119 { 120 return nation; 121 } 122 string staff::getMajor() 123 { 124 return major; 125 } 126 int staff::getPost() 127 { 128 return post; 129 } 130 int staff::getPartment() 131 { 132 return partment; 133 } 134 int staff::getPosition() 135 { 136 return position; 137 }
stafflist.h
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #pragma once 2 #include"staff.h" 3 4 #include<string> 5 6 class stafflist 7 { 8 9 public: 10 stafflist(); 11 ~stafflist(); 12 13 14 15 void addItem(staff *st); 16 17 18 void initFromFile(string path); 19 void saveToFile(string path); 20 21 staff* getItemByNum(int i); 22 bool showItemsByName(string s); 23 24 25 void printAll(); 26 void disByPost(int i); 27 void disByPartment(int i); 28 void resetammount(); 29 30 void deleteByNum(int i); 31 void release(); 32 33 int getAm_post(int i); 34 int getAm_partment(int i); 35 36 private: 37 38 staff *front; //员工链表首地址 39 int am_post[4],am_partment[4]; //各类员工总数量 40 41 42 43 };
stafflist.cpp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include "stdafx.h" 2 #include "stafflist.h" 3 #include"staff.h" 4 #include<fstream> 5 #include<string> 6 stafflist::stafflist() 7 { 8 front = NULL; 9 am_post[0] = 0; 10 am_post[1] = 0; 11 am_post[2] = 0; 12 am_post[3] = 0; 13 am_partment[0] = 0; 14 am_partment[1] = 0; 15 am_partment[2] = 0; 16 am_partment[3] = 0; 17 } 18 //从文件中初始化员工数据 19 void stafflist::initFromFile(string path) 20 { 21 ifstream ifile(path, ios_base::in | ios_base::out); 22 23 if (ifile.fail()) 24 { 25 ofstream ofile; 26 ofile.open(path); 27 ofile.close(); 28 } 29 30 string Name, Nation, Major; 31 int Num, Age, Post, Position, Partment, Edu; 32 if (ifile >> Num >> Name >> Age >> Edu >> Nation >> Major >> Post >> Partment >> Position) 33 { 34 front = new staff(Num, Name, Age, Edu, Nation, Major, Post, Partment, Position); 35 } 36 staff* curr = front; 37 while (ifile >> Num >> Name >> Age >> Edu >> Nation >> Major >> Post >> Partment >> Position) 38 { 39 40 staff *next = new staff(Num, Name, Age, Edu, Nation, Major, Post, Partment, Position); 41 42 curr->next = next; 43 curr = curr->next; 44 45 46 } 47 ifile.close(); 48 } 49 //将员工数据保存到文件 50 void stafflist::saveToFile(string path) 51 { 52 staff* curr; 53 curr = front; 54 ofstream ofile(path,ios_base::trunc); 55 56 while (curr != NULL) 57 { 58 ofile << curr->getNum() << ' ' << curr->getName() << ' ' << curr->getAge() << ' ' << curr->getEdu() << ' ' << curr->getNation() << ' ' << curr->getMajor() << ' ' << curr->getPost() <<' '<< curr->getPartment() << ' ' << curr->getPosition()<<endl; 59 curr = curr->next; 60 } 61 ofile.close(); 62 63 } 64 stafflist::~stafflist() 65 { 66 67 68 } 69 //添加员工至列表末 70 void stafflist::addItem(staff *st) 71 { 72 staff* curr; 73 if (front == NULL)front = st; 74 else 75 { 76 77 78 curr = front; 79 while (curr->next!= NULL) 80 { 81 82 83 curr = curr->next; 84 85 } 86 curr->next = st; 87 } 88 } 89 90 //通过姓名查找并输出员工信息 91 bool stafflist::showItemsByName(string s) 92 { 93 staff* curr; 94 curr = front; 95 bool showed = false; 96 while (curr != NULL) 97 { 98 99 if (curr->getName() == s) 100 { 101 curr->display(); 102 showed = true; 103 } 104 curr = curr->next; 105 106 } 107 return showed; 108 } 109 110 111 //通过编号查找员工 112 staff* stafflist::getItemByNum(int i) 113 { 114 staff* curr; 115 curr = front; 116 while (curr != NULL) 117 { 118 119 if (curr->getNum() == i)return curr; 120 curr = curr->next; 121 122 } 123 return NULL; 124 } 125 //按部门显示员工信息 126 void stafflist::disByPartment(int i) 127 { 128 129 staff* curr; 130 curr = front; 131 while (curr != NULL) 132 { 133 134 if (curr->getPartment() == i) 135 { 136 curr->display(); 137 138 } 139 curr = curr->next; 140 141 } 142 } 143 //按职称显示员工信息 144 void stafflist::disByPost(int i) 145 { 146 147 staff* curr; 148 curr = front; 149 while (curr != NULL) 150 { 151 152 if (curr->getPost() == i) 153 { 154 curr->display(); 155 156 } 157 curr = curr->next; 158 159 } 160 } 161 //显示所有员工信息 162 void stafflist::printAll() 163 { 164 staff* curr; 165 curr = front; 166 167 while (curr != NULL) 168 { 169 170 curr->display(); 171 curr = curr->next; 172 173 } 174 } 175 //重新计数各部门员工数量 176 void stafflist::resetammount() 177 { 178 for (int i = 0; i < 4; i++) 179 { 180 am_post[i] = 0; 181 am_partment[i] = 0; 182 staff* curr; 183 curr = front; 184 while (curr != NULL) 185 { 186 187 if (curr->getPost() == i) 188 { 189 am_post[i]++; 190 191 } 192 if (curr->getPartment() == i) 193 { 194 am_partment[i]++; 195 } 196 curr = curr->next; 197 198 } 199 } 200 } 201 //获取某部门员工数量 202 int stafflist::getAm_partment(int i) 203 { 204 return am_partment[i]; 205 } 206 //获取某职称员工数量 207 int stafflist::getAm_post(int i) 208 { 209 return am_post[i]; 210 } 211 212 //按编号删除 213 void stafflist::deleteByNum(int i) 214 { 215 staff *curr = front; 216 staff*prev = curr; 217 if (front->getNum() == i) 218 { 219 front = front->next; 220 delete curr; 221 } 222 else 223 { 224 225 226 while (curr != NULL) 227 { 228 if (curr->getNum() == i) 229 { 230 prev->next = curr->next; 231 delete curr; 232 break; 233 } 234 235 prev = curr; 236 curr = curr->next; 237 238 239 } 240 } 241 } 242 //释放所有节点 243 void stafflist::release() 244 { 245 staff *curr, *next; 246 curr = front; 247 while (curr != NULL) 248 { 249 next = curr->next; 250 delete curr; 251 curr = next; 252 } 253 254 }
staffsystem.cpp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 // staffsystem.cpp : 定义控制台应用程序的入口点。 2 // 3 4 #include "stdafx.h" 5 #include "staff.h" 6 #include"stafflist.h" 7 #include<iomanip> 8 #include <iostream> 9 #include<fstream> 10 #include<string> 11 using namespace std; 12 13 int _tmain(int argc, _TCHAR* argv[]) 14 { 15 const string mm = "gly1475"; 16 //调节控制台显示 17 system("mode con cols=100 "); 18 19 string edu[]={"小学","初中","高中","本科","硕士","博士","教授"}; 20 string post[]={"助理工程师","工程师","高级工程师","教授级高级工程师"}; 21 string partment[]={"人事部","技术部","后勤部","信息部"}; 22 string position[]={"普通员工","工程师","团队领导","部门领导","公司领导"}; 23 24 stafflist Stafflist; 25 Stafflist.initFromFile("config.txt"); 26 Stafflist.resetammount(); 27 28 29 30 31 int menu; 32 33 34 cout<<"-------------------------------------------员工管理系统---------------------------------------\n\n"; 35 cout<<" [1] 输出所有员工信息\n"; 36 cout<<" [2] 增加员工\n"; 37 cout<<" [3] 删除员工\n"; 38 cout<<" [4] 根据姓名查询\n"; 39 cout<<" [5] 根据编号查询\n"; 40 cout<<" [6] 显示各部门员工数量\n"; 41 cout<<" [7] 查询各部门员工信息\n"; 42 cout<<" [8] 查询各职称员工信息\n"; 43 cout<<" [0] 清屏\n"; 44 cout<<" [-1]退出\n\n"; 45 cout<<" 温馨提示:选择功能时,务必输入整数否则程序会出错!\n"; 46 cout<<" 所有操作输入-1 则返回\n"; 47 cout<<" by 计算机1408班 傅攀\n"; 48 cout<<"---------------------------------------------------------------------------------------------\n"; 49 50 while (1) 51 { 52 cout << "---------------------------------------------------------------------------------------------\n"; 53 cout << "选择功能:"; 54 cin >> menu; 55 56 57 switch (menu) 58 { 59 case -1: 60 { 61 cout << "确定退出? [1]确定 [其他]取消\n"; 62 int optionOK; 63 cin >> optionOK; 64 if (optionOK == 1) 65 { 66 Stafflist.release(); 67 return 0; 68 } 69 70 }break; 71 case 0: 72 { 73 system("cls"); 74 75 cout << "-------------------------------------------员工管理系统---------------------------------------\n\n"; 76 cout << " [1] 输出所有员工信息\n"; 77 cout << " [2] 增加员工\n"; 78 cout << " [3] 删除员工\n"; 79 cout << " [4] 根据姓名查询\n"; 80 cout << " [5] 根据编号查询\n"; 81 cout << " [6] 显示各部门员工数量\n"; 82 cout << " [7] 查询各部门员工信息\n"; 83 cout << " [8] 查询各职称员工信息\n"; 84 cout << " [0] 清屏\n"; 85 cout << " [-1]退出\n\n"; 86 cout << " 温馨提示:选择功能时,务必输入整数否则程序会出错!\n"; 87 cout << " 所有操作输入-1 则返回\n"; 88 cout << " by 计算机1408班 傅攀\n"; 89 cout << "---------------------------------------------------------------------------------------------\n"; 90 }break; 91 case 1: 92 { 93 cout << setiosflags(ios::left); 94 cout << setw(10) << "员工编号" << setw(10) << "姓名" << setw(6) << "年龄" << setw(6) << "教育" << setw(6) << "民族" << setw(10) << "专业" << setw(20) << "职称" << setw(8) << "部门" << setw(10) << "职位" << endl; 95 Stafflist.printAll(); 96 }break; 97 case 2: 98 { 99 100 cout << "添加员工操作面板,请根据提示操作!\n请提供管理员权限,输入口令:"; 101 string password; 102 cin >> password; 103 while (password != mm&&password != "-1") 104 { 105 cout << "口令错误,重新输入,-1返回\n"; 106 cin >> password; 107 if (password == "-1") break; 108 } 109 if (password == "-1")break; 110 111 112 staff *st = new staff(); 113 cout << "口令正确!\n请输入员工编号:"; 114 int i_num; 115 cin >> i_num; 116 117 while (Stafflist.getItemByNum(i_num) != NULL&&i_num != -1) 118 { 119 cout << "该员工已存在,请重新输入编号!-1返回\n"; 120 cin >> i_num; 121 if (i_num == -1)break; 122 } 123 if (i_num == -1)break; 124 125 st->setNum(i_num); 126 127 cout << "请输入员工姓名:"; 128 string s_name; 129 cin >> s_name; 130 if (s_name == "-1")break; 131 st->setName(s_name); 132 cout << "请输入员工年龄:"; 133 int i_age; 134 cin >> i_age; 135 if (i_age == -1)break; 136 st->setAge(i_age); 137 cout << "请输入员工受教育程度\n[0]小学 [1]初中 [2]高中 [3]本科 [4]硕士 [5]博士 [6]教授\n"; 138 int i_edu; 139 cin >> i_edu; 140 while (i_edu < -1 || i_edu>6) 141 { 142 cout << "输入错误!重新输入!-1返回\n"; 143 cin >> i_edu; 144 if (i_edu == -1)break; 145 } 146 if (i_edu == -1)break; 147 st->setEdu(i_edu); 148 149 cout << "请输入员工民族:"; 150 string s_nation; 151 cin >> s_nation; 152 if (s_nation == "-1")break; 153 st->setNation(s_nation); 154 cout << "请输入员工专业:"; 155 string s_major; 156 cin >> s_major; 157 if (s_major == "-1")break; 158 st->setMajor(s_major); 159 cout << "请输入员工职称\n[0]助理工程师 [1]工程师 [2]高级工程师 [3]教授级工程师\n"; 160 int i_post; 161 cin >> i_post; 162 while (i_post < -1 || i_post>3) 163 { 164 cout << "输入错误!重新输入!-1返回\n"; 165 cin >> i_post; 166 if (i_post == -1)break; 167 168 } 169 if (i_post == -1)break; 170 st->setPost(i_post); 171 172 cout << "请输入员工部门\n[0]人事部 [1]技术部 [2]后勤部 [3]信息部\n"; 173 int i_partment; 174 cin >> i_partment; 175 while (i_partment < -1 || i_partment>3) 176 { 177 cout << "输入错误!重新输入!-1返回\n"; 178 cin >> i_partment; 179 if (i_partment == -1)break; 180 181 } 182 if (i_partment == -1)break; 183 st->setPartment(i_partment); 184 185 cout << "请输入员职位\n[0]普通员工 [1]工程师 [2]团队领导 [3]部门领导 [4]公司领导\n"; 186 int i_position; 187 cin >> i_position; 188 while (i_position < -1 || i_position>4) 189 { 190 cout << "输入错误!重新输入!-1返回\n"; 191 cin >> i_position; 192 if (i_position == -1)break; 193 194 } 195 if (i_position == -1)break; 196 st->setPosition(i_position); 197 198 st->display(); 199 cout << "确认添加? [1]确认 [其他]取消\n"; 200 int optionOK; 201 cin >> optionOK; 202 if (optionOK == 1) 203 { 204 Stafflist.addItem(st); 205 Stafflist.saveToFile("config.txt"); 206 cout << "成功添加!\n"; 207 } 208 else cout << "已放弃添加\n"; 209 210 211 212 213 214 }break; 215 case 3: 216 { 217 cout << "删除员工操作面板,请根据提示操作!\n"; 218 cout << "输入员工编号:\n"; 219 int i_num; 220 cin >> i_num; 221 222 staff *st; 223 st = Stafflist.getItemByNum(i_num); 224 while (st == NULL&&i_num != -1) 225 { 226 cout << "该员工不存在!无需删除,重新输入,-1返回\n"; 227 cin >> i_num; 228 if (i_num == -1)break; 229 st = Stafflist.getItemByNum(i_num); 230 } 231 if (i_num == -1)break; 232 233 st->display(); 234 cout << "确定删除?[1]确定 [其他]取消\n"; 235 int optionOK; 236 cin >> optionOK; 237 if (optionOK == 1) 238 { 239 Stafflist.deleteByNum(i_num); 240 Stafflist.resetammount(); 241 Stafflist.saveToFile("config.txt"); 242 243 } 244 else 245 { 246 cout << "操作已取消\n"; 247 248 249 } 250 251 252 }break; 253 case 4: 254 { 255 cout << "查找员工操作面板\n请输入查找员工姓名:"; 256 string s_name; 257 cin >> s_name; 258 259 260 while (!Stafflist.showItemsByName(s_name)&&s_name != "-1") 261 { 262 cout << "该员工不存在!重新输入\n"; 263 cin >> s_name; 264 if (s_name == "-1")break; 265 266 } 267 if (s_name == "-1")break; 268 269 270 271 272 273 274 }break; 275 case 5: 276 { 277 cout << "查找员工操作面板\n请输入员工编号:"; 278 int i_num; 279 cin >> i_num; 280 staff* st = Stafflist.getItemByNum(i_num); 281 while (st == NULL&&i_num != -1) 282 { 283 cout << "该员工不存在!重新输入\n"; 284 cin >> i_num; 285 if (i_num == -1)break; 286 st = Stafflist.getItemByNum(i_num); 287 } 288 if (i_num == -1)break; 289 290 st->display(); 291 cout << "是否操作?[1]是 [其他]否\n"; 292 int j; 293 cin >> j; 294 if (j == 1) 295 { 296 297 cout << "[0]删除该员工 [1]修改姓名 [2]修改年龄 [3]修改受教育程度 [4]修改民族 [5]修改专业 [6]修改职称 [7]修改部门 [8]修改职务\n"; 298 int i; 299 cin >> i; 300 if (i == 0) 301 { 302 303 Stafflist.deleteByNum(st->getNum()); 304 Stafflist.resetammount(); 305 Stafflist.saveToFile("config.txt"); 306 cout << "删除成功!\n"; 307 308 309 } 310 else if (i == 1) 311 { 312 cout << "姓名:" << st->getName() << endl << "修改为:"; 313 string s_name; 314 cin >> s_name; 315 st->setName(s_name); 316 cout << "员工" << st->getNum() << "姓名被修改为:" << st->getName() << endl; 317 } 318 else if (i == 2) 319 { 320 cout << "年龄:" << st->getAge() << endl << "修改为:"; 321 int i_age; 322 cin >> i_age; 323 st->setAge(i_age); 324 cout << "员工" << st->getNum() << "年龄被修改为:" << st->getAge() << endl; 325 } 326 else if (i == 3) 327 { 328 cout << "受教育程度:" << edu[st->getEdu()] << endl << "修改为:[0]小学 [1]初中 [2]高中 [3]本科 [4]硕士 [5]博士 [6]教授\n"; 329 int i_edu; 330 cin >> i_edu; 331 while (i_edu < 0 || i_edu>6) 332 { 333 cout << "选择错误,请重新选择:"; 334 cin >> i_edu; 335 } 336 st->setEdu(i_edu); 337 cout << "员工" << st->getNum() << "受教育程度被修改为:" << edu[st->getEdu()] << endl; 338 339 340 } 341 else if (i == 4) 342 { 343 cout << "民族" << st->getNation() << endl << "修改为:"; 344 string s_nation; 345 cin >> s_nation; 346 st->setNation(s_nation); 347 cout << "员工" << st->getNum() << "姓名被修改为:" << st->getNation() << endl; 348 349 350 } 351 else if (i == 5) 352 { 353 cout << "专业" << st->getMajor() << endl << "修改为:"; 354 string s_major; 355 cin >> s_major; 356 st->setMajor(s_major); 357 cout << "员工" << st->getNum() << "专业被修改为:" << st->getMajor() << endl; 358 } 359 else if (i == 6) 360 { 361 cout << "职称:" << post[st->getPost()] << endl << "修改为:[0]助理工程师 [1]工程师 [2]高级工程师 [3]教授级工程师\n"; 362 int i_post; 363 cin >> i_post; 364 while (i_post < 0 || i_post>3) 365 { 366 cout << "选择错误,请重新选择:"; 367 cin >> i_post; 368 } 369 st->setPost(i_post); 370 cout << "员工" << st->getNum() << "职称被修改为:" << post[st->getPost()] << endl; 371 } 372 else if (i == 7) 373 { 374 cout << "部门:" << partment[st->getPartment()] << endl << "修改为:[0]人事部 [1]技术部 [2]后勤部 [3]信息部\n"; 375 int i_partment; 376 cin >> i_partment; 377 while (i_partment < 0 || i_partment>3) 378 { 379 cout << "选择错误,请重新选择:"; 380 cin >> i_partment; 381 } 382 st->setPartment(i_partment); 383 cout << "员工" << st->getNum() << "职称被修改为:" << partment[st->getPartment()] << endl; 384 } 385 else if (i == 8) 386 { 387 cout << "职位:" << partment[st->getPartment()] << endl << "修改为:[0]普通员工 [1]工程师 [2]团队领导 [3]部门领导 [4]公司领导\n"; 388 int i_position; 389 cin >> i_position; 390 while (i_position < 0 || i_position>4) 391 { 392 cout << "选择错误,请重新选择:"; 393 cin >> i_position; 394 } 395 st->setPosition(i_position); 396 cout << "员工" << st->getNum() << "职位被修改为:" << position[st->getPosition()] << endl; 397 } 398 Stafflist.saveToFile("config.txt"); 399 } 400 401 }break; 402 case 6: 403 { 404 cout << "各部门员工人数:\n"; 405 for (int i = 0; i < 4; i++) 406 { 407 cout << partment[i] << ":" << Stafflist.getAm_partment(i) << " 人 "; 408 } 409 cout << endl; 410 }break; 411 case 7: 412 { 413 414 cout << "按部门查看员工信息面板\n[0]人事部 [1]技术部 [2]后勤部 [3]信息部\n"; 415 int i_partment; 416 cin >> i_partment; 417 while (i_partment < -1 || i_partment>3) 418 { 419 cout << "输入错误,重新输入\n"; 420 cin >> i_partment; 421 if (i_partment == -1)break; 422 } 423 if (i_partment == -1)break; 424 425 cout << partment[i_partment] << endl; 426 Stafflist.disByPartment(i_partment); 427 428 cout << "当前部门总人数为:" << Stafflist.getAm_partment(i_partment) << endl; 429 430 }break; 431 case 8: 432 { 433 cout << "按职称查看员工信息面板\n[0]助理工程师 [1]工程师 [2]高级工程师 [3]教授级高级工程师\n"; 434 int i_position; 435 cin >> i_position; 436 while (i_position < -1 || i_position>3) 437 { 438 cout << "输入错误,重新输入\n"; 439 cin >> i_position; 440 if (i_position == -1)break; 441 } 442 if (i_position == -1)break; 443 444 cout << post[i_position] << endl; 445 Stafflist.disByPost(i_position); 446 447 cout << "当前职称总人数为:" << Stafflist.getAm_post(i_position) << endl; 448 449 450 }break; 451 default: 452 { 453 cout << "输入错误请重新选择功能\n"; 454 455 456 } 457 } 458 } 459 return 0; 460 }
程序实验报告:百度云下载