1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
| #include <iostream> #include<stdio.h> #include <string.h> #include <conio.h> using namespace std; int mmyz() { int i,n=0,j; char k[6]; char h[]={"123456"}; cout<<"请输入系统的6位初始密码"<<endl; for(i=0;i<3;i++) { for(j=0;j<6;j++) { k[j]=getch(); cout<<"*"; } if(strcmp(k,h)==0) { cout<<"密码正确\n"<<endl; cout<<"成功进入系统"<<endl; break; } else { printf("\n密码错误,请重新输入\n"); n++; } if(n==3) { printf("禁止登陆!\n");break;} } return(n); }
class company{ public: int num; string name; int basicwage; int postwage; //岗位工资 int bonus; //奖金 int salary; //应发工资 int funds; //公积金 float deduthetax; //税收 float thp; //实发工资 company(){}; company(int n,string na,int ba,int po,int bo,int sa,int f,float de,float th):num(n),name(na),basicwage(ba),postwage(po),bonus(bo),salary(sa),funds(f),deduthetax(de),thp(th){} void setdata(); void display(); friend void add(company &stu,int a); }; void company::display(){ cout<<"工号:"<<num<<endl; cout<<"姓名:"<<name<<endl; cout<<"基本工资:"<<basicwage<<endl; cout<<"岗位工资:"<<postwage<<endl; cout<<"奖金:"<<bonus<<endl; cout<<"应发工资:"<<salary<<endl; cout<<"公积金:"<<funds<<endl; cout<<"税收:"<<deduthetax<<endl; cout<<"实发工资:"<<thp<<endl; } void add(company *stu,int a){ int b,i; cout<<"请输入插入个数"<<endl; cin>>b; cout<<"输入插入数据:"<<endl; for(i=a;i<a+b;i++){ stu[i].setdata(); } a=a+b; } void change(company *stu,int a){ int c,i; cout<<"输入要修改的员工编号"<<endl; cin>>c; cout<<"输入要修改后员工数据"<<endl; for(i=0;i<a;i++){ if(stu[i].num==c){ stu[i].setdata(); } } } void delet(company *stu,int a){ int d,i; cout<<"输入要删除的员工编号"<<endl; cin>>d; for(i=0;i<a;i++){ if(stu[i].num==d){ for(;i<a;i++){ stu[i]=stu[i+1]; } } } a=a-1; } void sum(company *stu,int a){ int i; int e=0; //员工总工资 for(i=0;i<a;i++){ e=e+stu[i].thp; } cout<<"员工总工资为:" <<e<<endl; } void search(company *stu,int a){ int f,i; cout<<"输入要查询的员工编号"<<endl; cin>>f; for(i=0;i<a;i++){ if(stu[i].num==f){ stu[i].display(); } } } void sort(company *stu,int a){ int i,j; float tmp; for(i=0;i<a;i++){ for(j=i+1;j<a;j++){ if(stu[i].thp>stu[j].thp){ tmp=stu[i].thp; stu[i].thp=stu[j].thp; stu[j].thp=tmp; } } } } void outpu(company *stu,int a){ int i; for(i=0;i<a;i++){ stu[i].display(); } } void company::setdata(){ cin>>num; cin>>name; cin>>basicwage; cin>>postwage; cin>>bonus; cin>>salary; cin>>funds; cin>>deduthetax; cin>>thp; } /* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) { int z; z=mmyz(); if(z==3){ return 0; } int i; int n; //功能序号 int a; //输入员工个数 company st[100]; company *stu=st; cout<<"输入员工个数"<<endl; cin>>a; cout<<"输入数据(编号,姓名,基本工资,岗位工资,奖励,应发工资,公积金,税收,实发工资)"<<endl; for(i=0;i<a;i++){ stu[i].setdata(); cout<<endl; } //输入函数 cout<<"1:添加 " "2:修改 " "3:删除 " "4:统计 " "5:查询 " "6:按实发工资排序 " "7:输出 " "8:退出系统 "; cout<<endl; cout<<"输入功能号"<<endl; cin>>n; while(n>=1&&n<8){ if(n==1){ add(stu,a); cout<<"请输入功能号"<<endl; cin>>n; } if(n==2){ change(stu,a); cout<<"请输入功能号"<<endl; cin>>n; } if(n==3){ delet(stu,a); cout<<"请输入功能号"<<endl; cin>>n; } if(n==4){ sum(stu,a); cout<<"请输入功能号"<<endl; cin>>n; } if(n==5){ search(stu,a); cout<<"请输入功能号"<<endl; cin>>n; } if(n==6){ sort(stu,a); cout<<"请输入功能号"<<endl; cin>>n; } if(n==7){ outpu(stu,a); cout<<"请输入功能号"<<endl; cin>>n; } } return 0; }
|