欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C++實(shí)現(xiàn)職工工資管理系統(tǒng)

 更新時(shí)間:2022年03月01日 09:47:27   作者:瑪珈山大萌新  
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)簡單的職工工資管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C++實(shí)現(xiàn)職工工資管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

main.cpp

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <windows.h>
#include "data.h"
#include "user.h"
#include "fuction1-9.h"
#include "fuction10.h"
#include "menu.h"
using namespace std;
int main()
{
?? ?system("color 3f");
?? ?if (login() == false)
?? ??? ?return 0;
?? ?load_inf();
?? ?while (show_menu());
?? ?save_inf();
?
?? ?return 0;
}

data.h

#pragma once
const int maxn = 100;
using namespace std;
struct department
{
?? ?int code;
?? ?int number;
?? ?string department_name;
?? ?void show_inf() { printf("%50s部門號:%-6d部門名稱:%-12s部門人數(shù):%-6d\n", "", code, department_name.c_str(), number); }
};
map<int, department> dep;//部門表的映射
struct employee
{
?? ?int code;
?? ?string name;
?? ?string gender;
?? ?int working_age;
?? ?int department_code;//部門編碼
?? ?void show_inf() { printf("%50s編號:%-6d姓名:%-12s性別:%-9s工齡(年):%-6d部門:%-12s\n", "", code, name.c_str(), gender.c_str(), working_age, dep[department_code].department_name.c_str()); }
};
map<int, employee> emp;///存儲數(shù)據(jù)的容器
struct wage
{
?? ?int code;
?? ?int base_wage;//基本工資
?? ?int overtime;//加班工資
?? ?int bonus;//津貼
?? ?int gross_pay;//應(yīng)發(fā)工資
?? ?int withholding;//代扣款
?? ?int payment; //實(shí)發(fā)工資
?? ?void show_inf() { printf("%30s員工號:%-6d員工姓名:%-12s基本工資:%-6d\t加班工資:%-6d\t津貼:%-6d\t應(yīng)發(fā)工資:%-6d\t代扣款:%6d\t實(shí)發(fā)工資:%6d\n", "", code, emp[code].name.c_str(), base_wage, overtime, bonus, gross_pay, withholding, payment); }
?? ?void calculate() { gross_pay = base_wage + overtime + bonus, payment = gross_pay - withholding; }
};
map<int, wage> wag;

fuciton1-9.h

#pragma once
using namespace std;
void load_inf()
{
?? ?FILE *p;
?? ?char s[maxn];
?
?? ?system("cls");
?? ?if ((p = fopen("employee.txt", "r")) == NULL)
?? ?{
?? ??? ?printf("%70s數(shù)據(jù)異常,無法訪問!\n", "");
?? ??? ?system("pause");
?? ??? ?exit(0);
?? ?}
?? ?while (fgets(s, 100, p))
?? ?{
?? ??? ?int code;
?? ??? ?char name[maxn];
?? ??? ?char gender[maxn];
?? ??? ?int working_age;
?? ??? ?int department_code;
?
?? ??? ?sscanf(s, "%d %s %s %d %d", &code, name, gender, &working_age, &department_code);
?? ??? ?emp[code] = (employee{ code, name, gender, working_age, department_code });
?? ?}
?? ?printf("%70s", "");
?? ?for (int i = 0; i < 5; i++) { cout << "."; Sleep(200); }
?? ?printf("員工信息導(dǎo)入成功!\n");
?? ?cout << endl;
?? ?fclose(p);
?? ?if ((p = fopen("department.txt", "r")) == NULL)
?? ?{
?? ??? ?printf("%70s數(shù)據(jù)異常,無法訪問!\n", "");
?? ??? ?system("pause");
?? ??? ?exit(0);
?? ?}
?? ?while (fgets(s, 100, p))
?? ?{
?? ??? ?int code;
?? ??? ?int number;
?? ??? ?char department_name[maxn];
?
?? ??? ?sscanf(s, "%d %d %s", &code, &number, department_name);
?? ??? ?dep[code] = { code, number, department_name };
?? ?}
?? ?printf("%70s", " ");
?? ?for (int i = 0; i < 5; i++) { cout << "."; Sleep(200); }
?? ?printf("部門信息導(dǎo)入成功!\n");
?? ?cout << endl;
?? ?fclose(p);
?? ?if ((p = fopen("wage.txt", "r")) == NULL)
?? ?{
?? ??? ?printf("%70s數(shù)據(jù)異常,無法訪問!", "");
?? ??? ?system("pause");
?? ??? ?exit(0);
?? ?}
?? ?while (fgets(s, 100, p))
?? ?{
?? ??? ?int code;//員工號
?? ??? ?int base_wage;//基本工資
?? ??? ?int overtime;//加班工資
?? ??? ?int bonus;//津貼
?? ??? ?int gross_pay;
?? ??? ?int withholding;//代扣款
?? ??? ?int payment;
?
?? ??? ?sscanf(s, "%d %d %d %d %d %d %d", &code, &base_wage, &overtime, &bonus, &gross_pay, &withholding, &payment);
?? ??? ?wag[code] = (wage{ code, base_wage, overtime, bonus, gross_pay, withholding, payment });
?? ?}
?? ?printf("%70s", " ");
?? ?for (int i = 0; i < 5; i++) { cout << "."; Sleep(200); }
?? ?printf("工資信息導(dǎo)入成功!\n");
?? ?cout << endl;
?? ?fclose(p);
?? ?return;
}
void save_inf()
{
?? ?FILE *p = fopen("employee.txt", "w");
?? ?char inf[maxn];
?
?? ?for (auto it = emp.begin(); it != emp.end(); it++)
?? ?{
?? ??? ?sprintf(inf, "%d %s %s %d %d\n", it->second.code, it->second.name.c_str(), it->second.gender.c_str(), it->second.working_age, it->second.department_code);
?? ??? ?fputs(inf, p);
?? ?}
?? ?printf("%70s", " ");
?? ?for (int i = 0; i < 5; i++) { cout << "."; Sleep(200); }
?? ?printf("員工信息保存成功!\n");
?? ?fclose(p);
?? ?p = fopen("department.txt", "w");
?? ?for (auto it = dep.begin(); it != dep.end(); it++)
?? ?{
?? ??? ?sprintf(inf, "%d %d %s\n", it->second.code, it->second.number, it->second.department_name.c_str());
?? ??? ?fputs(inf, p);
?? ?}
?? ?printf("%70s", "");
?? ?for (int i = 0; i < 5; i++) { cout << "."; Sleep(200); }
?? ?printf("部門信息保存成功!\n");
?? ?fclose(p);
?? ?p = fopen("wage.txt", "w");
?? ?for (auto it = wag.begin(); it != wag.end(); it++)
?? ?{
?? ??? ?sprintf(inf, "%d %d %d %d %d %d %d\n", it->second.code, it->second.base_wage, it->second.overtime, it->second.bonus, it->second.gross_pay, it->second.withholding, it->second.payment);
?? ??? ?fputs(inf, p);
?? ?}
?? ?printf("%70s", "");
?? ?for (int i = 0; i < 5; i++) { cout << "."; Sleep(200); }
?? ?printf("工資信息保存成功!\n");
?? ?fclose(p);
?? ?return;
}
/以下為部門表的操作
void add_dep()
{
?? ?printf("%70s請輸入要添加的部門號:", "");
?? ?int code; cin >> code;
?? ?string department_name;
?
?? ?if (!dep.count(code))
?? ?{
?? ??? ?printf("%70s請輸入部門名稱:", "");
?? ??? ?while (1)
?? ??? ?{
?? ??? ??? ?int flag = 0;
?? ??? ??? ?cin >> department_name;
?? ??? ??? ?for (auto it = dep.begin(); it != dep.end(); it++)
?? ??? ??? ??? ?if (it->second.department_name == department_name)
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?printf("%70s該部門已存在, 請重新輸入!\n", "");
?? ??? ??? ??? ??? ?flag = 1;
?? ??? ??? ??? ?}
?? ??? ??? ?if (!flag) break;
?? ??? ?}
?? ??? ?dep[code] = { code, 0, department_name };
?? ??? ?printf("%70s部門添加成功!該部門信息如下:\n", "");
?? ??? ?dep[code].show_inf();
?? ?}
?? ?else
?? ??? ?printf("%70s該部門已存在!\n", "");
?? ?return;
}
void change_dep()
{
?? ?printf("%70s請輸入要修改的部門編號:", "");
?? ?int code; cin >> code;
?
?? ?if (!dep.count(code))
?? ??? ?printf("%70s該部門不存在!\n", "");
?? ?else
?? ?{
?? ??? ?printf("%70s該部門當(dāng)前信息如下:\n", "");
?? ??? ?dep[code].show_inf();
?? ??? ?printf("%70s請輸入部門的新名字:", "");
?? ??? ?while (1)
?? ??? ?{
?? ??? ??? ?string name; cin >> name;
?? ??? ??? ?int flag = 0;
?
?? ??? ??? ?for (auto it = dep.begin(); it != dep.end(); it++)
?? ??? ??? ??? ?if (it->second.department_name == name)
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?flag = 1;
?? ??? ??? ??? ??? ?break;
?? ??? ??? ??? ?}
?? ??? ??? ?if (flag)
?? ??? ??? ??? ?printf("%70s部門名字重復(fù)!請重新輸入\n", "");
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?dep[code].department_name = name;
?? ??? ??? ??? ?printf("%70s修改成功!\n", "");
?? ??? ??? ??? ?printf("%70s修改后的部門信息如下:\n", "");
?? ??? ??? ??? ?dep[code].show_inf();
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ?}
?? ?}
?? ?return;
}
void delete_dep()
{
?? ?printf("%70s請輸入要刪除的部門編號:", "");
?? ?int code; cin >> code;
?? ?if (!dep.count(code))
?? ??? ?printf("%70s該部門不存在,無法刪除!\n", "");
?? ?else if (!dep[code].number)//如果該部門沒有人,則可刪除
?? ?{
?? ??? ?for (auto it = dep.begin(); it != dep.end(); it++)
?? ??? ??? ?if (it->first == code)
?? ??? ??? ?{
?? ??? ??? ??? ?printf("%70s您刪除了%s\n", "", it->second.department_name.c_str());
?? ??? ??? ??? ?dep.erase(it);
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ?}
?? ?else
?? ??? ?printf("%70s該部門有員工,不可刪除!\n", "");
?? ?return;
}
/以下為員工表的操作
void add_emp()
{
?? ?printf("%70s請輸入要添加的員工號:", "");
?? ?int code; cin >> code;
?? ?if (!emp.count(code))
?? ?{
?? ??? ?emp[code].code = code;
?? ??? ?printf("%70s請輸入員工的姓名:", "");cin >> emp[code].name;
?? ??? ?printf("%70s請輸入員工的性別:", "");cin >> emp[code].gender;
?? ??? ?printf("%70s請輸入員工的工齡:", "");cin >> emp[code].working_age;
?? ??? ?printf("%70s請輸入員工的部門號:", "");
?? ??? ?int department_code;
?? ??? ?while (cin >> department_code && !dep.count(department_code))
?? ??? ??? ?printf("%70s該部門不存在,請重新輸入:", "");
?? ??? ?emp[code].department_code = department_code;
?? ??? ?dep[department_code].number++;
?? ??? ?printf("%70s員工信息添加成功!員工信息如下:\n", "");
?? ??? ?emp[code].show_inf();
?? ?}
?? ?else
?? ??? ?printf("%70s該員工號已存在\n", "");
?? ?return;
}
void change_emp()
{
?? ?int code;
?
?? ?printf("%70s請輸入要修改的員工號:", "");
?? ?while (cin >> code && !emp.count(code))
?? ??? ?printf("%70s該員工不存在!請重新輸入:", "");
?? ?printf("%70s該員工當(dāng)前信息如下:\n", "");
?? ?emp[code].show_inf();
?? ?printf("%70s請輸入修改后的工齡:", "");cin >> emp[code].working_age;
?? ?printf("%70s請輸入修改后的部門編碼:", "");
?? ?dep[emp[code].department_code].number--;///原部門人數(shù)減一
?? ?cin >> emp[code].department_code;
?? ?dep[emp[code].department_code].number++;//現(xiàn)部門人數(shù)加一
?? ?printf("%70s修改成功!修改之后的信息如下:\n", "");
?? ?emp[code].show_inf();
?? ?return;
}
void delete_emp()
{
?? ?printf("%70s請輸入要刪除的員工號:", "");
?? ?int code; cin >> code;
?? ?if (!emp.count(code))
?? ??? ?printf("%70s該員工不存在!無法刪除\n", "");
?? ?else
?? ?{
?? ??? ?dep[emp[code].department_code].number--;//原部門人數(shù)減一
?? ??? ?for (auto it = emp.begin(); it != emp.end(); it++)
?? ??? ??? ?if (it->first == code)
?? ??? ??? ?{
?? ??? ??? ??? ?printf("%70s您刪除的員工信息如下:\n", "");
?? ??? ??? ??? ?emp[it->second.code].show_inf();
?? ??? ??? ??? ?emp.erase(it);
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ?for (auto it = wag.begin(); it != wag.end(); it++)
?? ??? ??? ?if (it->first == code)
?? ??? ??? ?{
?? ??? ??? ??? ?wag.erase(it);
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ?}
?? ?return;
}
void add_wag()
{
?? ?printf("%70s請輸入錄入工資的員工編號:", "");
?? ?int code; cin >> code;
?
?? ?if (!emp.count(code))
?? ??? ?printf("%70s該員工不存在!\n", "");
?? ?else if (wag.count(code))
?? ??? ?printf("%70s該員工信息已錄入!\n", "");
?? ?else
?? ?{
?? ??? ?wag[code].code = code;
?? ??? ?printf("%70s請輸入員工的基本工資:", ""); cin >> wag[code].base_wage;
?? ??? ?printf("%70s請輸入員工的加班工資:", ""); cin >> wag[code].overtime;
?? ??? ?printf("%70s請輸入員工的津貼:", "");cin >> wag[code].bonus;
?? ??? ?printf("%70s請輸入員工的代扣款:", ""); cin >> wag[code].withholding;
?? ??? ?printf("%70s員工工資信息添加成功!\n", "");
?? ??? ?printf("%70s工資信息如下:\n", "");
?? ??? ?wag[code].calculate();
?? ??? ?wag[code].show_inf();
?? ?}
?? ?return;
}
void change_wag()
{
?? ?int code;
?
?? ?printf("%70s要修改者的編號:", "");
?? ?while (cin >> code && !wag.count(code))
?? ??? ?printf("%70s該員工不存在!請重新輸入\n", "");
?? ?printf("%70s該員工當(dāng)前的工資信息如下\n", "");
?? ?wag[code].show_inf();
?? ?printf("%70s請輸入基本工資:", ""); cin >> wag[code].base_wage;
?? ?printf("%70s請輸入加班工資:", "");cin >> wag[code].overtime;
?? ?printf("%70s請輸入津貼:", ""); cin >> wag[code].bonus;
?? ?printf("%70s請輸入代扣款:", ""); cin >> wag[code].withholding;
?? ?wag[code].calculate();
?? ?printf("%70s修改成功!修改之后的工資信息如下\n", "");
?? ?wag[code].show_inf();
?? ?return;
}
void delete_wag()
{
?? ?printf("%70s請輸入要刪除工資信息的員工編號:", "");
?? ?int code; cin >> code;
?? ?if (!wag.count(code))
?? ??? ?printf("%70s不存在該員工的工資信息\n", "");
?? ?else
?? ?{
?? ??? ?for (auto it = wag.begin(); it != wag.end(); it++)
?? ??? ??? ?if (it->first == code)
?? ??? ??? ?{
?? ??? ??? ??? ?wag.erase(it);
?? ??? ??? ??? ?printf("%70s刪除成功!\n", "");
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ?}
?? ?return;
}

fuction10.h

#pragma once
bool comp1(const int &a, const int &b)//升序
{
?? ?return wag[a].payment < wag[b].payment;
}
bool comp2(const int &a, const int &b)
{
?? ?return wag[a].payment > wag[b].payment;
}
?
bool search_inf()
{
?? ?system("cls");
?? ?printf("%70s0.返回\n", "");
?? ?printf("%70s1.查詢?nèi)繂T工的工資\n", "");
?? ?printf("%70s2.按員工號查詢員工工資\n", "");
?? ?printf("%70s3.按部門查詢員工工資\n", "");
?? ?printf("%70s4.按指定實(shí)發(fā)工資區(qū)間查詢員工工資\n", "");
?? ?printf("%70s5.按員工姓名查詢員工工資\n", "");
?? ?printf("%70s6.查詢?nèi)坎块T信息\n", "");
?? ?printf("%70s7.按編號查詢單個(gè)員工的基本信息\n", "");
?? ?printf("%70s8.按姓名查詢單個(gè)員工的基本信息\n", "");
?? ?printf("%70s9.顯示所有員工的基本信息\n", "");
?? ?printf("%70s請輸入操作編號[0-9]:", "");
?? ?int ope;
?? ?int code;
?? ?string name;
?? ?int dir;
?? ?int flag = 0;
?? ?long long sum = 0;
?? ?vector<int> temp; //存儲滿足查詢要求的人員編號
?
?? ?while (cin >> ope && !(ope >= 0 && ope <= 9))
?? ??? ?printf("%70s輸入非法,請重新輸入:", "");
?? ?if (!ope)
?? ??? ?return false;
?? ?switch (ope)
?? ?{
?? ?case 1:
?? ??? ?for (auto it = wag.begin(); it != wag.end(); it++)
?? ??? ?{
?? ??? ??? ?temp.push_back(it->first);
?? ??? ??? ?sum += it->second.payment;
?? ??? ?}
?? ??? ?printf("%70s1.按實(shí)發(fā)工資升序\n", "");
?? ??? ?printf("%70s2.按實(shí)發(fā)工資降序\n", "");
?? ??? ?printf("%70s請輸入操作類型:", "");
?? ??? ?while (cin >> dir && dir != 1 && dir != 2)
?? ??? ??? ?printf("%70s輸入非法,請重新輸入!\n", "");
?? ??? ?if (dir == 1)
?? ??? ??? ?sort(temp.begin(), temp.end(), comp1);
?? ??? ?else
?? ??? ??? ?sort(temp.begin(), temp.end(), comp2);
?? ??? ?for (int i = 0; i < (int)temp.size(); i++)
?? ??? ??? ?wag[temp[i]].show_inf();
?? ??? ?printf("%144s合計(jì): %10lld\n", "", sum);
?? ??? ?break;
?? ?case 2:
?? ??? ?printf("%70s請輸入要查詢的員工號:", "");
?? ??? ?cin >> code;
?? ??? ?if (!emp.count(code))
?? ??? ??? ?printf("%70s該員工不存在!\n", "");
?? ??? ?else if (!wag.count(code))
?? ??? ??? ?printf("%70s該員工的工資信息未錄入!\n", "");
?? ??? ?else
?? ??? ??? ?wag[code].show_inf();
?? ??? ?break;
?? ?case 3:
?? ??? ?printf("%70s請輸入所要查詢員工的部門:", "");
?? ??? ?cin >> code;
?? ??? ?if (!dep.count(code))
?? ??? ??? ?printf("%70s該部門不存在!\n", "");
?? ??? ?else
?? ??? ?{
?? ??? ??? ?for (auto it = wag.begin(); it != wag.end(); it++)
?? ??? ??? ??? ?if (emp[it->first].department_code == code)
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?temp.push_back(it->first);
?? ??? ??? ??? ??? ?sum += it->second.payment;
?? ??? ??? ??? ?}
?? ??? ??? ?printf("%70s1.按實(shí)發(fā)工資升序\n", "");
?? ??? ??? ?printf("%70s2.按實(shí)發(fā)工資降序\n", "");
?? ??? ??? ?printf("%70s請輸入操作類型:", "");
?? ??? ??? ?while (cin >> dir && dir != 1 && dir != 2)
?? ??? ??? ??? ?printf("%70s輸入非法,請重新輸入!\n", "");
?? ??? ??? ?if (dir == 1)
?? ??? ??? ??? ?sort(temp.begin(), temp.end(), comp1);
?? ??? ??? ?else
?? ??? ??? ??? ?sort(temp.begin(), temp.end(), comp2);
?? ??? ??? ?for (int i = 0; i < (int)temp.size(); i++)
?? ??? ??? ??? ?wag[temp[i]].show_inf();
?? ??? ??? ?printf("%144s合計(jì): %10lld\n", "", sum);
?? ??? ?}
?? ??? ?break;
?? ?case 4:
?? ??? ?int up, down;
?
?? ??? ?printf("%70s請輸入實(shí)發(fā)工資區(qū)間的上限:", "");
?? ??? ?cin >> up;
?? ??? ?printf("%70s請輸入實(shí)發(fā)工資區(qū)間的下限:", "");
?? ??? ?cin >> down;
?? ??? ?if (up < down)
?? ??? ??? ?printf("%70s非法的輸入!\n", "");
?? ??? ?else
?? ??? ?{
?? ??? ??? ?for (auto it = wag.begin(); it != wag.end(); it++)
?? ??? ??? ??? ?if (it->second.payment >= down && it->second.payment <= up)
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?temp.push_back(it->first);
?? ??? ??? ??? ??? ?sum += it->second.payment;
?? ??? ??? ??? ?}
?? ??? ??? ?if (!temp.size())
?? ??? ??? ?{
?? ??? ??? ??? ?printf("%70s查詢不到符合條件的員工!\n", "");
?? ??? ??? ??? ?cout << "" << endl;
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ??? ?printf("%70s1.按實(shí)發(fā)工資升序\n", "");
?? ??? ??? ?printf("%70s2.按實(shí)發(fā)工資降序\n", "");
?? ??? ??? ?printf("%70s請輸入操作類型:", "");
?? ??? ??? ?int dir; cin >> dir;
?? ??? ??? ?if (dir == 1)
?? ??? ??? ??? ?sort(temp.begin(), temp.end(), comp1);
?? ??? ??? ?else
?? ??? ??? ??? ?sort(temp.begin(), temp.end(), comp2);
?? ??? ??? ?for (int i = 0; i < (int)temp.size(); i++)
?? ??? ??? ??? ?wag[temp[i]].show_inf();
?? ??? ??? ?printf("%144s合計(jì): %10lld\n", "", sum);
?? ??? ?}
?? ??? ?break;
?? ?case 5:
?? ??? ?printf("%70s請輸入員工姓名:", "");
?? ??? ?cin >> name;
?? ??? ?for (auto it = emp.begin(); it != emp.end(); it++)
?? ??? ??? ?if (it->second.name == name)
?? ??? ??? ?{
?? ??? ??? ??? ?wag[it->first].show_inf();
?? ??? ??? ??? ?flag = 1;
?? ??? ??? ?}
?? ??? ?if (!flag)
?? ??? ??? ?printf("%70s查詢不到此人!\n", "");
?? ??? ?break;/這個(gè)不需要排序,考慮到會有重名
?? ?case 6:
?? ??? ?for (auto it = dep.begin(); it != dep.end(); it++)
?? ??? ??? ?dep[it->first].show_inf();
?? ??? ?break;
?? ?case 7:
?? ??? ?printf("%70s請輸入員工編號:", "");
?? ??? ?cin >> code;
?? ??? ?
?? ??? ?if (!emp.count(code))
?? ??? ??? ?printf("%70s該員工不存在!\n", "");
?? ??? ?else
?? ??? ??? ?emp[code].show_inf();
?? ??? ?break;
?? ?case 8:
?? ??? ?printf("%70s請輸入員工姓名:", "");
?? ??? ?cin >> name;
?
?? ??? ?for(auto it = emp.begin(); it != emp.end(); it++)
?? ??? ??? ?if (it->second.name == name)
?? ??? ??? ?{
?? ??? ??? ??? ?flag = 1;
?? ??? ??? ??? ?emp[it->second.code].show_inf();
?? ??? ??? ?}
?? ??? ?if (!flag)
?? ??? ??? ?printf("%70s查詢不到此人!\n", "");
?? ??? ?break;
?? ?case 9:
?? ??? ?for (auto it = emp.begin(); it != emp.end(); it++)
?? ??? ??? ?emp[it->second.code].show_inf();
?? ??? ?break;
?? ?default:
?? ??? ?return false;
?? ?}
?? ?system("pause");
?? ?return true;
}

menu.h

#pragma once
using namespace std;
bool show_menu()
{
?? ?int dir;
?? ?system("cls");//清屏
?? ?printf("%70s*************************\n", "");
?? ?printf("%70s歡迎進(jìn)入職工工資管理系統(tǒng)!\n", "");
?? ?printf("%70s*************************\n", "");
?? ?printf("%70s0. 退出系統(tǒng)\n", "");
?? ?printf("%70s1. 部門信息錄入\n", "");
?? ?printf("%70s2. 部門信息修改\n", "");
?? ?printf("%70s3. 部門信息刪除\n", "");
?? ?printf("%70s4. 員工信息錄入\n", "");
?? ?printf("%70s5. 員工信息修改\n", "");
?? ?printf("%70s6. 員工信息刪除\n", "");
?? ?printf("%70s7. 員工工資錄入\n", "");
?? ?printf("%70s8. 員工工資修改\n", "");
?? ?printf("%70s9. 員工工資刪除\n", "");
?? ?printf("%70s10.信息查詢\n", "");
?? ?printf("%70s11.修改登錄密碼\n", "");
?? ?printf("%70s請輸入操作選項(xiàng)[0-11]:", "");
?? ?while (cin >> dir && (dir < 0 || dir > 11)) printf("%70s非法指令,請重新輸入:\n", "");
?? ?switch (dir)
?? ?{
?? ?case 0:
?? ??? ?return false;
?? ?case 1:
?? ??? ?system("cls");
?? ??? ?add_dep();
?? ??? ?system("pause");
?? ??? ?break;
?? ?case 2:
?? ??? ?system("cls");
?? ??? ?change_dep();
?? ??? ?system("pause");
?? ??? ?break;
?? ?case 3:
?? ??? ?system("cls");
?? ??? ?delete_dep();
?? ??? ?system("pause");
?? ??? ?break;
?? ?case 4:
?? ??? ?system("cls");
?? ??? ?add_emp();
?? ??? ?system("pause");
?? ??? ?break;
?? ?case 5:
?? ??? ?system("cls");
?? ??? ?change_emp();
?? ??? ?system("pause");
?? ??? ?break;
?? ?case 6:
?? ??? ?system("cls");
?? ??? ?delete_emp();
?? ??? ?system("pause");
?? ??? ?break;
?? ?case 7:
?? ??? ?system("cls");
?? ??? ?add_wag();
?? ??? ?system("pause");
?? ??? ?break;
?? ?case 8:
?? ??? ?system("cls");
?? ??? ?change_wag();
?? ??? ?system("pause");
?? ??? ?break;
?? ?case 9:
?? ??? ?system("cls");
?? ??? ?delete_wag();
?? ??? ?system("pause");
?? ??? ?break;
?? ?case 10:
?? ??? ?while (search_inf());
?? ??? ?break;
?? ?case 11:
?? ??? ?system("cls");
?? ??? ?reset_passwd();
?? ??? ?system("pause");
?? ??? ?break;
?? ?default:
?? ??? ?return false;
?? ?}
?? ?return true;
}

user.h

#pragma once
using namespace std;
bool login()
{
?? ?int chance = 3;
?? ?char temp[maxn];
?? ?char passwd[maxn];
?? ?FILE *p;
?? ?if ((p = fopen("passwd.txt", "r")) == NULL)
?? ?{
?? ??? ?printf("%80s數(shù)據(jù)異常,無法訪問!\n", "");
?? ??? ?fclose(p);
?? ??? ?exit(0);
?? ?}
?? ?fgets(passwd, 100, p);
?? ?//cout << passwd << endl;
?? ?fclose(p);
?? ?printf("%70s********************\n", "");
?? ?printf("%70s歡迎使用工資管理系統(tǒng)!\n", "");
?? ?printf("%70s********************\n", "");
?? ?while (chance--)
?? ?{
?? ??? ?printf("%70s請輸入登錄密碼:", "");
?? ??? ?scanf("%s", temp);
?? ??? ?if (!strcmp(temp, passwd))
?? ??? ?{
?? ??? ??? ?printf("%70s密碼正確!\n", "");
?? ??? ??? ?return true;
?? ??? ?}
?? ??? ?else printf("%70s密碼錯(cuò)誤!你還剩%d次機(jī)會!\n", "", chance);
?? ??? ?if (!chance) printf("%70s非法用戶!\n", "");
?? ?}
?? ?return false;
}
?
void reset_passwd()
{
?? ?char temp1[maxn], temp2[maxn];
?? ?char passwd[maxn];
?? ?FILE *p;
?? ?printf("%70s請輸入3-10位不含空格的密碼:", "");
?? ?while (scanf("%s", temp1) && (strlen(temp1) < 3 && strlen(temp1) > 10))
?? ??? ?printf("%70s密碼非法,請重新輸入\n", "");
?? ?printf("%70s請?jiān)俅屋斎胄薷拿艽a:", "");
?? ?scanf("%s", temp2);
?? ?if (!strcmp(temp1, temp2))
?? ?{
?? ??? ?p = fopen("passwd.txt", "w");
?? ??? ?fgets(passwd, 100, p);
?? ??? ?strcpy(passwd, temp1);
?? ??? ?fputs(passwd, p);
?? ??? ?fclose(p);
?? ??? ?printf("%70s修改成功!\n", "");
?? ?}
?? ?else printf("%70s修改失?。n", "");
?? ?return;
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C++實(shí)現(xiàn)簡易通訊錄

    C++實(shí)現(xiàn)簡易通訊錄

    這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)簡易通訊錄,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-07-07
  • C++ 壓縮文件及文件夾方法 使用zlib開源庫

    C++ 壓縮文件及文件夾方法 使用zlib開源庫

    下面小編就為大家分享一篇C++ 壓縮文件及文件夾方法 使用zlib開源庫,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • C語言可變參數(shù)列表的用法與深度剖析

    C語言可變參數(shù)列表的用法與深度剖析

    這篇文章主要給大家介紹了關(guān)于C語言可變參數(shù)列表的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2022-02-02
  • 用32位int型變量表示單引號括起來的四個(gè)字符的深入探討

    用32位int型變量表示單引號括起來的四個(gè)字符的深入探討

    本篇文章是對用32位int型變量表示單引號括起來的四個(gè)字符進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • 帶你理解C語言中的漢諾塔公式

    帶你理解C語言中的漢諾塔公式

    大家好,本篇文章主要講的是帶你理解C語言中的漢諾塔公式,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下
    2022-01-01
  • C++中一維數(shù)組與指針的關(guān)系詳細(xì)總結(jié)

    C++中一維數(shù)組與指針的關(guān)系詳細(xì)總結(jié)

    以下是對C++中一維數(shù)組與指針的關(guān)系進(jìn)行了詳細(xì)的總結(jié)介紹,需要的朋友可以過來參考下
    2013-09-09
  • 使用Qt的QChartView實(shí)現(xiàn)縮放和放大功能

    使用Qt的QChartView實(shí)現(xiàn)縮放和放大功能

    QCustomPlot是一個(gè)小型的Qt畫圖標(biāo)類,支持繪制靜態(tài)曲線、動態(tài)曲線、多重坐標(biāo)曲線,柱狀圖,蠟燭圖,這篇文章主要介紹了Qt的QChartView實(shí)現(xiàn)縮放和放大功能,需要的朋友可以參考下
    2022-09-09
  • vs2022?x64?C/C++和匯編混編(案例代碼)

    vs2022?x64?C/C++和匯編混編(案例代碼)

    這篇文章主要介紹了vs2022?x64?C/C++和匯編混編,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-02-02
  • C語言實(shí)現(xiàn)掃雷游戲小項(xiàng)目

    C語言實(shí)現(xiàn)掃雷游戲小項(xiàng)目

    這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)掃雷游戲小項(xiàng)目,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • 從零學(xué)習(xí)cmake構(gòu)建系統(tǒng)

    從零學(xué)習(xí)cmake構(gòu)建系統(tǒng)

    這篇文章主要為大家介紹了從零學(xué)習(xí)cmake構(gòu)建系統(tǒng)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02

最新評論