职工工资纳税管理信息系统 c 项目 源代码 功能强大

合集下载

员工工资管理系统c语言编程

员工工资管理系统c语言编程

#include<stdio.h>#include<string.h>#include<ctype.h>#include<malloc.h>#define null 0typedef struct Info1{char num[10];char name[10];char depar[10];char yfsalary[10];char aband[10];char tax[10];char sfsalary[10];struct Info1 *next;}Info2;typedef struct Info1 *Info;Info head;void display();void find();void modify();void add();void del();void list();void listOne(Info s);Info isExists(char *num);void init();void init(){head=(Info)malloc(sizeof(Info2));head->next=null;}void main(){init();while(1){char c;display();scanf("%c",&c);switch(c){case '1':find();break;case '2':add();break;case '3':modify();break;case '4':del();break;case '5':list();break;case '6':printf("\t\t...退出系统!\n");return;default: printf("\t\t输入错误!请按任意键返回重新选择(1-7)\n");getchar();}}}void display(){printf("\n\t** 欢迎使用员工信息管理系统**\n\n");printf("\t请选(1-7):\n");printf("\t============================================\n");printf("\t\t1.查询员工信息\n");printf("\t\t2.录入员工信息\n");printf("\t\t3.修改员工信息\n");printf("\t\t4.删除员工信息\n");printf("\t\t6.显示所有员工信息\n");printf("\t\t7.退出系统\n");printf("\t============================================\n");printf("\t您的选择是: ");}void listOne(Info p){printf("\n该员工信息记录如下: ");printf("\n==========================================================\n\n");printf("%-12s%-10s%-10s%-7s%-7s%-10s%-10s%\n","员工编号","姓名","部门","应付工资","保险","税金","实付工资");printf("%-12s%-10s%-10s%-7s%-7s%-10s%-10s%\n",p->num,p->name,p->depar,p->yfsalary,p->aband,p->tax ,p->sfsalary);}Info isExists(char *num){Info p,q;p=head;q=p->next;while(q!=null){if(strcmp(q->num,num)==0)return p;p=q;q=p->next;}return p;}void add(){Info p,q;char num[10];q=(Info)malloc(sizeof(Info2));printf("\t\t请输入员工编号: ");scanf("%s",num);p=isExists(num);if (p->next==null){strcpy(q->num,num);printf("\t\t请输入员工姓名: ");scanf("%s",q->name);printf("\t\t请输入该员工的部门: ");scanf("%s",q->depar);printf("\t\t请输入该员工的应付工资金额: ");scanf("%s", q->yfsalary);printf("\t\t请输入该员工的保险金额: ");scanf("%s", q->aband);printf("\t\t请输入该员工的税金金额: ");scanf("%s",q->tax);printf("\t\t请输入该员工的实付工资: ");scanf("%s",q->sfsalary);q->next=null;p->next=q;}elseprintf("\n\t\t您所输入的员工编号以存在! ");printf("\n\t\t按任意键返回住菜单......");getchar();}void del(){Info p,q;char num[10];if (head->next==null){printf("\n\t\t当前还没有员工信息记录,按任意键返回主菜单......");getchar();return;}printf("\t\t请输入员工编号: ");scanf("%s",num);p=isExists(num);q=p->next;if (q!=null){q=q->next;p->next=q;printf("\n\t\t删除成功! ");}elseprintf("\n\t\t您所输入的员工编号有误或不存在! ");printf("\n\t\t按任意键返回主菜单......");getchar();}void modify(){Info p,q;char num[10];if (head->next==null){printf("\n\t\t当前还没有员工信息记录,按任意键返回主菜单......");getchar();return;}printf("\t\t请输入员工编号: ");scanf("%s",num);p=isExists(num);q=p->next;if(q!=null){listOne(q);printf("\t\t请输入该员工的新姓名: ");scanf("%s",q->name);printf("\t\t请输入该员工的部门: ");scanf("%s",q->depar);printf("\t\t请输入该员工的应付工资金额: ");scanf("%s",q->yfsalary);printf("\t\t请输入该员工的保险: ");scanf("%s",q->aband);printf("\t\t请输入该员工的新税金金额: ");scanf("%s",q->tax);printf("\t\t请输入该员工的新实付工资: ");scanf("%s",q->sfsalary);}elseprintf("\n\t\t您所输入的员工编号有误或不存在!");printf("\n\t\t按任意键返回主菜单......");getchar();}void list(){Info p;if (head->next==null){printf("\n\t\t当前还没有员工信息记录,按任意键返回主菜单......");getchar();return;}printf("\n所有员工信息记录如下: ");printf("\n========================================================================\n\n");printf("%-12s%-10s%-10s%-7s%-7s%-10s%-10s%\n","员工编号","姓名","部门","应付工资","保险","税金","实付金额");p=head->next;while(p!=null){printf("%-12s%-10s%-10s%-7s%-7s%-10s%-10s%\n",p->num,p->name,p->depar,p->yfsalary,p->aband,p->tax ,p->sfsalary);p=p->next;}printf("\n\t\t按任意键返回主菜单......");getchar();}void find(){Info p;char num[10];if (head->next==null){printf("\n\t\t当前还没有员工信息记录,按任意键返回主菜单......");getchar();return;}printf("\t\t输入员工编号: ");scanf("%s",num);p=isExists(num);p=p->next;if(p!=null)listOne(p);elseprintf("\n\t\t您所输入的员工信息有误或不存在!");printf("\n\t\t按任意键返回主菜单......");getchar();}。

c语言课程设计职工工资管理系统源代码

c语言课程设计职工工资管理系统源代码

绝对可以完美运行,下面有运行图片#include<stdio.h> //调用库函数#include<string.h> //字符串处理#include<conio.h> //控制台输入输出#include<stdlib.h> //定义杂项函数及内存分配函数#define N 2 //宏定义以3代替N/******************************************************************************函数声明*******************************************************************************/ void enter();int menu();void input();void output();void search();void search_employeeid();void search_name();void edit();void array();void array_basesalary();void array_postwage();void array_totalwage();void statistics();void save();void load();/******************************************************************************职工类型定义*******************************************************************************/ struct employee{char employeeid[10];char name[10];char sex[10];int age;float basesalary;float postwage;float totalwage;};/******************************************************************************职工变量定义******************************************************************************/ struct employee emp[N];struct employee replace;struct employee *p=emp;/*****************************************************************************系统主函数******************************************************************************/ void main(){int c;while(1){printf(" \n\n\n\n");printf(" 欢迎进入职工工资管理系统\n\n\n");printf(" 1 进入管理系统\n\n");printf(" 0 退出\n\n");printf(" \n\n\n\n");printf(" 请输入你选择:\n");scanf("%d",&c);switch(c){case 1:enter();break;case 0:printf(" 谢谢使用!\n");exit(0);}}}/***************************************************************************** 功能:登陆函数,进行密码验证*****************************************************************************/ void enter(){char q;char key[10],password[10]="china";int k=1,i;printf(" 请输入密码:\n");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}while(k<=3){if(strncmp(key,password,5)==0){while(1){int a;//system("cls");a=menu();switch(a){case 1:input();break;case 2:output();break;case 3:search();break;case 4:edit();break;case 5:array();break;case 6:load();statistics();break;case 0:printf("\n\n 谢谢使用!\n\n\n\n");save();exit(0);}}}else{k++;printf(" 输入密码错误!请再次输入:");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}if(k>2){if(strncmp(password,key,5)==0)continue;else{printf(" 输入密码错误三次,系统将自动退出!\n");exit(0);}}}}}/************************************************************************功能: 主菜单函数参数:a类型:int说明: 变量返回值: a************************************************************************/int menu(){int a ;printf("\n\n");printf("|*****************欢迎进入职工工资管理系统************************|\n");printf("| |\n");printf("| |\n");printf("| 1 职工信息输入|\n");printf("| |\n");printf("| 2 职工信息输出|\n");printf("| |\n");printf("| 3 职工信息查询|\n");printf("| |\n");printf("| 4 职工信息修改|\n");printf("| |\n");printf("| 5 工资排序|\n");printf("| |\n");printf("| 6 工资统计|\n");printf("| |\n");printf("| 0 退出|\n");printf("| |\n");printf("| |\n");printf("|*****************************************************************|\n");printf("\n\n");printf(" 请输入你所选择的选项:");scanf("%d",&a);while(a>6||a<0){printf(" error!\n");printf(" 请重新输入你所选择的选项:");scanf("%d",&a);}return a;}/********************************************************************************* ***功能:职工信息输入********************************************************************************** ***/void input(){int c;p=emp;printf(" 进入职工信息输入模块\n\n\n");for(c=0;c<N;c++,p++){p[c].totalwage=p[c].basesalary+p[c].postwage;printf(" 请输入第%d个职工信息:\n\n",c+1);printf(" 请输入职工号:\n");scanf("%s",p->employeeid);if(strcmp(p->employeeid,"0")!=0){printf(" 请输入职工姓名:\n");scanf("%s",p->name);printf(" 请输入职工性别: \n");scanf("%s",&p->sex);printf(" 请输入职工年龄: \n");scanf("%d",&p->age);printf(" 请输入职工基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入职工岗位工资:\n");scanf("%f",&p->postwage);printf(" 职工信息输入完成!\n\n");}elsereturn;}save();}/******************************************************************************* 功能:职工信息输出********************************************************************************/ void output(){int j;load();p=emp;printf(" 进入职工信息输出模块\n\n\n");printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("-------------------------------------------------------------------------------\n");for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");}printf("\n\n 职工信息输出完成!\n\n");getchar();}/******************************************************************************功能:职工信息查询******************************************************************************/ void search(){int j;while(1){printf("*********************职工信息查询*********************\n\n\n");printf(" 1 按职工号查询\n");printf(" 2 按职工姓名查询\n");printf(" 0 退出该项操作\n");printf("\n\n");while(1){printf(" 请输入你的选择\n");scanf("%d",&j);if(j>=0&&j<=2){switch(j){case 1:search_employeeid();break;case 2:search_name();break;case 0:return;}}else{printf(" 输入错误!\n\n");printf(" 请再次输入你的选择: \n\n");}}}}/******************************************************************************* 功能:按职工号查询函数*******************************************************************************/ void search_employeeid(){char employeeid[10];int k,j;p=emp;printf("*********************按职工号查询职工信息*****************************\n\n\n\n");printf(" 请输入要查询职工的职工号:\n\n");scanf("%s",employeeid);for(k=0;k<N;k++){if(strcmp(employeeid,p->employeeid)==0){j=k;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found\n");return;}}}/*****************************************************************************功能:按职工姓名查询函数*****************************************************************************/ void search_name(){char name[10];int flog=0;int f,j;p=emp;printf("******************************按职工姓名查询职工信息***********************\n\n\n");printf(" 请输入要查询职工的姓名:\n\n");scanf("%s",name);for(f=0;f<N;f++,p++){if(strcmp(name,p->name)==0){j=f;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found \n\n");return;}}getchar();}/*******************************************************************************功能:职工信息修改函数*******************************************************************************/ void edit(){char e[10];int g=0,j;char flog;p=emp;printf(" 请输入你要修改职工的职工号:\n");scanf("%s",e);for(g=0;g<N;g++){// if(*e==p[g].employeeid)if(strcmp(e,p->employeeid)==0){j=g;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p[j].sex ,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");printf(" 是否要修改该职工信息?y(是)or n(否)?\n\n");getchar();scanf("%c",&flog);if(flog == 'y'){printf(" 请输入新姓名:\n");scanf("%s",p->name);printf(" 请输入性别:\n");scanf("%s",&p->sex);printf(" 请输入年龄:\n");scanf("%d",&p->age);printf(" 请输入基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入岗位工资:\n");scanf("%f",&p->postwage);printf(" 修改职工信息成功!\n\n");}if(flog == 'n'){printf(" 退出该项操作!\n\n");return;}save();}if(g==N){printf(" not found \n\n\n");return;}}}/************************************************************************ 功能:职工工资排列函数************************************************************************/ void array(){int j;while(1){printf("*************************工资排序*********************\n\n");printf(" 1 按基本工资排序\n\n");printf(" 2 按岗位工资排序\n\n");printf(" 3 按总工资排列\n\n");printf(" 0 退出\n\n");printf("\n\n\n");while(1){printf(" 请输入你的选择:\n\n");scanf("%d",&j);if(j>=0&&j<=3){switch(j){case 1:array_basesalary();break;case 2:array_postwage();break;case 3:array_totalwage();break;case 0:return;}}else{printf(" 输入错误!\n\n\n");printf(" 请再次输入你的选择:\n\n");}}}}/**************************************************************************功能:按基本工资排列(选择法)***************************************************************************/void array_basesalary(){int i,j,k;p=emp;for(i=0;i<N-1;i++){k=i;for(j=i+1;j<N;j++){if(p[k].basesalary<p[j].basesalary)k=j;}if(k!=i){replace=emp[k];emp[k]=emp[i];emp[i]=replace;}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按岗位工资排列(冒泡法)*************************************************************************/void array_postwage(){int i,j;p=emp;for(i=0;i<N;i++){for(j=0;j<N-i;j++){if(p[j].postwage<p[j+1].postwage){replace=emp[j];emp[j]=emp[j+1];emp[j+1]=replace;}}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按总工资排列(插入法)************************************************************************/void array_totalwage(){int i,j;p=emp;for(i=1;i<N;i++){replace=emp[i];for(j=i-1;j>=0&&p[i].totalwage>p[i].totalwage;j--){emp[j+1]=emp[j];emp[j+1]=replace;}}for(j=N-1;j>=0;j--){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别| 年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/*************************************************************************功能:工资统计函数**************************************************************************/void statistics(){int z,a=0,b=0,c=0;p=emp;for(z=0;z<N;z++){if(p[z].totalwage>3000){a++;continue;}if(p[z].totalwage>=2000&&p[z].totalwage<=3000){b++;continue;}if(p[z].totalwage<=2000&&p[z].totalwage>0){c++;continue;}}printf(" 总工资在3000元以上的职工人数有:%d\n\n",a);printf(" 总工资在2000元至3000元的职工人数有:%d\n\n",b);printf(" 总工资在2000元以下的职工人数有:%d\n\n",c);getchar();}/*************************************************************************** 功能:导出函数***************************************************************************/ void save(){int k;FILE *fp;p=emp;if((fp=fopen("emp_list","wb"))==NULL){printf(" Create file error!\n");return;}for(k=0;k<N;k++,p++){if(fwrite(p,sizeof(struct employee),1,fp)!=1){printf(" file save error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}/***********************************************************************功能:导入函数***********************************************************************/ void load(){int l;FILE *fp;p=emp;if((fp=fopen("emp_list","rb"))==NULL){printf(" Create file error!\n");exit(0);}for(l=0;l<N;l++,p++){if(fread(p,sizeof(struct employee),1,fp)!=1){printf(" file read error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}下面是实验结果。

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio.h>#include<string.h>typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息.txt”文献写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文献读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@在使用中产生的任何问题, 欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen("职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salary.basic,&st[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen("账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen("密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf("请输入账号:");scanf("%s",x);getchar();printf("请输入密码:");scanf("%s",y);getchar();f=fyanzheng(x,y);if (d>3){printf("错误次数太多, 退出系统\n");return 0;}if (f>0) break;else{printf("账号或密码输入错误, 请重新输入\n");d++;}}printf("\n");printf("欢迎进入员工工资管理系统\n");return 1;}void Print_MainInterface(){int x;printf("\n");printf("*************************华丽的分割线*************************\n");printf("\n");printf("1.职工信息录入\n");printf("2.职工信息查询\n");printf("3.职工工资排序\n");printf("4.记录职工总工资\n");printf("5.保存到文献\n");printf("6.退出职工工资系统\n");printf("请选择所需操作:");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();elseif (x==6){printf(" ****** **** **** * * ***** * *\n");printf("* * * * * * * * * * *\n");printf("* * * * * * * * * * *\n");printf(" ****** ******** ******** ** * * * *\n");printf(" * * * ** * * * *\n");printf(" * * * ** * * * *\n");printf(" ****** **** **** ** ***** ***** \n");// printf("333333\n");return;}else{printf("输入命令错误, 返回主菜单(再乱输入我找人打你啊)\n");Print_MainInterface();}}void Print_Interface_1(){n++;if (n>500){printf("超过职工最大数\n");Print_MainInterface();}printf("\n");printf("*************************妖精的分割线*************************\n"); printf("\n");printf("新建职工号:");scanf("%s",st[n].num);printf("姓名:");scanf("%s",st[n].name);printf("年龄:");scanf("%d",&st[n].age);printf("性别:");scanf("%s",st[n].sex);printf("基本工资:");scanf("%d",&st[n].salary.basic);printf("津贴:");scanf("%d",&st[n].salary.subsidy);printf("奖金:");scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages;printf("职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf("*************************逗比的分割线*************************\n");printf("\n");printf("1.查询所有职工\n");printf("2.按职工号查询\n");printf("3.按职工姓名查询\n");printf("4.返回主菜单\n");printf("请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf("请输入职工工号:");scanf("%s",y);Print_empl1(y);}elseif (x==3){printf("请输入职工姓名:");scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf("输入命令错误, 返回上一层\n");Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf("排序完毕!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf("所有职工的总工资为:%d\n",All);printf("请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen("职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basic,st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf("已保存到文献\n");printf("\n");printf("请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf("*************************帅比的分割线*************************");printf("\n");for (i=1;i<=n;i++){printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");}printf("返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]){int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0){t=i;d=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (d>0){printf("如需删除请按2,修改请按1,返回请按0\n");scanf("%d",&y);if (y==2)Print_delete(t);elseif (y==1)Print_Interface_2_1(t);elseif (y==0)Print_Interface_2();else{printf("输入命令错误, 返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不涉及路人甲乙丙, 不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf("如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1)Print_Interface_2_1(t);elseif (x==0)Print_Interface_2();else{printf("输入命令错误, 返回上一层\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不涉及路人甲乙丙, 不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf("已删除该职工并排序, 自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf("请选择以下选项:\n");printf("1.职工号\n");printf("2.姓名\n");printf("3.年龄\n");printf("4.性别\n");printf("5.基本工资\n");printf("6.津贴\n");printf("7.奖金\n");printf("8.返回上一层\n");printf("9.返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2:scanf("%s",st[t].name);break;case 3:scanf("%d",st[t].age);break;case 4:scanf("%s",st[t].sex);break;case 5:scanf("%s",st[t].salary.basic);break;case 6:scanf("%d",st[t].salary.subsidy);break;case 7:scanf("%d",st[t].salary.wages);break;}st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9)Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);}。

c语言课程实践《职工工资管理系统》源代码

c语言课程实践《职工工资管理系统》源代码
else if(mn==0)
fprintf(report,"\n\tAverage wage\t\t%.2f\t\t0.00\t\t%.2f",(float)(fsum/fn),(float)(fsum/fn));//如果男性人数是0,则只输出女性的平均工资
else
fprintf(report,"\n\tAverage wage\t\t%.2f\t\t%.2f\t\t%.2f",(float)(fsum/fn),(float)(msum/mn),(float)((fsum+msum)/(fn+mn)));//如果男女都不为0的话,那么则把平均工资都输出
p=temp;//temp指针变量往后移
temp=temp->next;//temp指针变量往后移
}
if(fnum==temp->num)//如果找到了,就执行下面的程序
{
find=1;//标记变量:find是1的时候说明找到,0则说明没找到
printf("\n");
unsigned int age; // 年龄
unsigned long telephone,wage,num; // 电话,工资,编号
struct workers *next; // 指向下一条记录的指针(链表使用)
};
struct workers *head,*bottom,*temp,*p;//定义指向结构体的指针变量
insert();//调用创建链表,录入信息的函数
}
getchar();//输入任意字符
return main();//返回主调函数
}

C员工工资管理系统源代码

C员工工资管理系统源代码

#include 〈iomanip〉#include 〈iostream〉#include <fstream>#include 〈malloc.h〉#include <stdlib。

h〉#include 〈string.h>using namespace std;#define NULL 0#define LEN sizeof(struct student)int const N=20;void Menu();void Pass();int n=0; //定义一个全局变量统计职工人数//————-——————>定义一个职工信息的结构体struct student{char name[N]; //用来存放姓名char sex[N];//用来存放性别long id; //用来存放编号float paid[3];//用来存放工资int total; //用来存放总工资struct student *next;};//-—---————-——-—〉职工类class Information{public:Information();//构造函数.~Information() ; //析构函数。

student *creat(); //建立链表void output(student *head); //显示职工信息int count(student *head);//定义函数count()统计职工总数student *insert(student*head);//指针函数*insert()用来添加职工信息。

student *cancel(student *head,long id); //指针函数*cancel()用来删除职工信息。

student *find(student *head,long id); //指针函数*find()用来查找职工信息。

student *modify(student *head,long id); //指针函数*modife()用来修改职工的信息. void paixu(student *head);//定义paixu()函数将职工的总额从大到小排列并输出void average(student *head);//定义职工工资平均值的函数void save(student *head); //保存文件信息student *Read(); //读取文件信息private:student *p1,*p2,*p3,*head,st;};Information::Information(){cout<<” ******************************************************************************\n";cout〈〈" --—-—-——---—-—---—----——〈<欢迎您使用员工工资管理系统>〉-—-———---—————-——-—-—-——\n";cout<<” ******************************************************************************\n\n”;}Information::~Information(){cout<〈” ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n”;cout〈〈” \n";cout<<" 本系统管理员\n";cout〈<” \n”;cout〈<" \n";cout〈〈" --———-—--———-—-——--—-—--<〈谢谢您使用员工工资管理系统>>———--—-------——---—-———-\n";cout〈〈” \n";cout<<"\n";cout〈〈" 欢迎下次使用\n";cout<〈" \n”;cout〈<" \n";cout<〈”再见\n";cout<<”\n”;cout〈〈” ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n";}//—--———--—-—->建立链表信息student *Information::creat(void){//定义一个指向struct student的结构体指针函数*creat()用来录入职工信息.char ch[N];n=0;//用来存放职工姓名p1=p2=(student *)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元cout〈〈" --—----------<<请建立员工信息表,在姓名处键以#结束输入!〉>--------—-—---”〈〈endl;cout<〈" 姓名:";cin〉〉ch;head=NULL; //给指针head赋初值while (strcmp(c h,”#")!=0){//调用字符比较函数strcmp()用来判断是否继续输入p1=(student *)malloc(LEN); //调用malloc()函数用来开辟一个新的存储单元strcpy(p1—>name,ch); //将循环结构前面输入的姓名复制到结构体名为p1的数组name中cout〈<”性别:";cin〉〉p1->sex;cout<<”编号:";cin>>p1—〉id;while((p1->id)〈0||(p1—〉id)>100000) //判断输入的编号是否有效(100000个) {cout<<" 对不起您的输入错误!请重新输入(〉0〈1000000):";cin>〉p1-〉id;}cout<<" 基本工资:";cin〉〉p1->paid[0];while((p1->paid[0])〈0||(p1—〉paid[0])>100000)//判断输入的分数是否有效(>=0 〈=100000){cout<<”对不起您的输入错误!请重新输入(〉0〈100000): ";cin>〉p1—〉paid[0];}cout〈<”加班工资:”;cin>〉p1—〉paid[1];while((p1—〉paid[1])<0||(p1->paid[1])>100000) //判断输入的分数是否有效(>=0 〈=100000){cout<〈" 对不起您的输入错误!请重新输入(〉0〈100000): ”;cin〉〉p1—>paid[1];}cout〈〈" 其他奖金:”;cin〉〉p1—〉paid[2];while((p1—>paid[2])〈0||(p1—〉paid[2])>100000)//判断输入的分数是否有效(>=0 <=100000){cout<<" 对不起您的输入错误!请重新输入(〉0〈100000):";cin>〉p1—>paid[2];}p1—>total=p1—>paid[0]+p1—>paid[1]+p1-〉paid[2]; //计算总额if(n==0)head=p1;//如果是输入第一组职工信息就将指针p1赋给指针headelse p2—>next=p1; //否则将p1赋给p2所指结构体的next指针p2=p1;//将指针p1赋给指针p2n++;//将职工人数n的值加1cout<〈"\n 姓名:”;cin〉>ch;//将输入的姓名存放到字符数组ch中}p2—〉next=NULL; //将p2所指结构体的next指针重新赋空值return (head);//将输入的第一组职工信息返回}//--—-———-————--->定义output()函数将职工的信息从头指针所指内容开始输出void Information::output(student *head){system("cls”);if(head==NULL)cout〈<”这是一个空表,请先输入员工信息!\n”;else{cout〈<"-—-——-—---———--—--—--—--——---—----—--------——------——-----——-—-—-—-—---——-—-——-\n";cout<〈”*职工工资信息表*\n”;cout<<"———-—-———-———-————————————---————--—----——-—--—-—-—-—-——-----——-—----------———-\n”;cout〈〈"|编号| |姓名| |性别||基本工资| |加班工资||其他奖金||总额|\n”;cout〈〈”-—-—-————————-———-——-————--—---——---—-—--——-—---——-——-—-——--—-———-—---—--—---——\n";p1=head;//将头指针赋给pdo{cout〈〈setw(6)〈<p1->id<<setw(10)〈<p1—>name〈<setw(10)〈<p1—>sex<<setw(10)〈〈p1-〉paid[0]<〈setw(10)〈<p1->paid[1]<〈setw(12)<〈p1-〉paid[2]〈<setw(12)<<p1—>total〈<endl;cout〈〈”-——--——---————---—-——-——-———-——---————-—-—----—-——---——-———-—-—-—-—----———--—--\n";p1=p1—〉next; //将下一组职工信息的next指针赋给p}while(p1!=NULL); //若指针p非空则继续,目的是把所有的职工信息都传给指针p 然后输出。

c语言职工工资管理系统代码

c语言职工工资管理系统代码

C语言职工工资管理系统代码简介职工工资管理是一项重要的任务,它涉及到工资计算、薪资发放、绩效评估等方面。

为了提高管理的有效性和准确性,许多公司和组织都开发了各种各样的工资管理系统。

本文将介绍一种基于C语言开发的职工工资管理系统代码。

代码功能及特点1. 基本功能•添加新员工信息•更新员工信息•计算员工工资•发放工资•查询员工信息•统计工资情况2. 特点•简单易懂:代码使用C语言编写,阅读和理解都相对简单。

•高效可靠:代码采用模块化设计,结构清晰,运行效率高,容错性强。

•跨平台支持:C语言是一种具有广泛应用的语言,可以在多个操作系统上运行。

代码实现1. 员工信息结构体定义struct Employee {int id; // 员工编号char name[20]; // 员工姓名float basicSalary; // 员工基本工资float performanceBonus; // 绩效奖金float salary; // 员工工资};2. 添加新员工信息函数void addEmployee(struct Employee *employee, int num) {printf("请输入员工编号:");scanf("%d", &(employee[num].id));// 输入其他员工信息...}3. 更新员工信息函数void updateEmployee(struct Employee *employee, int id) {int i;for (i = 0; i < num; i++) {if (employee[i].id == id) {// 更新员工信息...}}}4. 计算员工工资函数void calculateSalary(struct Employee *employee, int num) {int i;for (i = 0; i < num; i++) {employee[i].salary = employee[i].basicSalary + employee[i].performance Bonus;}}5. 发放工资函数void paySalary(struct Employee *employee, int num) {int i;for (i = 0; i < num; i++) {printf("员工编号:%d,工资:%.2f\n", employee[i].id, employee[i].salar y);}}6. 查询员工信息函数void searchEmployee(struct Employee *employee, int id) {int i;for (i = 0; i < num; i++) {if (employee[i].id == id) {// 输出员工信息...}}}7. 统计工资情况函数void statisticsSalary(struct Employee *employee, int num) { float totalSalary = 0;int i;for (i = 0; i < num; i++) {totalSalary += employee[i].salary;}printf("总工资:%f\n", totalSalary);}使用示例1. 添加员工信息struct Employee employees[100];int num = 0;addEmployee(employees, num);num++;2. 更新员工信息int id = 12345;updateEmployee(employees, id);3. 计算员工工资calculateSalary(employees, num);4. 发放工资paySalary(employees, num);5. 查询员工信息int id = 12345;searchEmployee(employees, id);6. 统计工资情况statisticsSalary(employees, num);总结本文介绍了一个基于C语言的职工工资管理系统代码。

C++职工工资管理系统源代码

C++职工工资管理系统源代码

附录〈源程序〉#include <stdio.h>#include <stdlib.h>#include <string.h>struct worker{char name[30];char ID[10];int salary1,salary2,salary3;};int dq(struct worker wo[]);void show();void bc(struct worker wo[]);void add();void see();void search();void ghcz();void xmcz();void del();void xmsc();void ghsc();void statistics();void modify();void ghxg();void xmxg();void reserve();void back();void author();struct worker wo[100]; //保存所有的职工信息int Number=0; //记录总的职工人数void main(){int choose=0;while(true){show();printf("\t\t====>请选择:");scanf("%d",&choose);system("cls");switch(choose){case 0: exit(0);//退出break;case 1: add();back();//添加职工信息break;case 2: see();back();//查看职工信息break;case 3: search();back();// 查找职工信息break;case 4: del();back();//删除职工信息break;case 5: statistics();back();//统计职工工资break;case 6: modify();back();//修改职工信息break;case 7:reserve();back();//保存数据break;case 8:author();back();//作者信息break;default:break;}fflush(stdin);getchar();system("cls");}}int dq(struct worker wo[]){FILE *fp=NULL;int i=0;fp=fopen("C://worker.dat","rb");while(fread(&wo[i],sizeof(struct worker),1,fp)) i++;fclose(fp);return i;}void show(){printf("\n");printf("\t****************职工工资管理系统****************\n\n"); printf("\t*☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆*\n\n"); printf("\t^^^^^^^^^^^^^^^[1] 添加职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[2] 查看职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[3] 查找职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[4] 删除职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[5] 统计职工工资^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[6] 修改职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[7] 保存数据^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[8] 作者信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[0] 退出系统^^^^^^^^^^^^^^^^^\n\n"); printf("\t*★★★★★★★★★★★★★★★★★★★★★★★*\n"); }void bc(struct worker *wo){FILE *fp=NULL;fp=fopen("C://worker.dat","ab+");fwrite(wo,sizeof(struct worker),1,fp);fclose(fp);}//添加职工信息void add(){int numberTemp=0;int i=0;struct worker temp;printf("请输入要添加职工个数:");scanf("%d",&numberTemp);for(i=0;i<numberTemp;i++){printf("输入第%d个职工信息\n",i+1);printf("姓名:");scanf("%s",);printf("工号:");scanf("%s",temp.ID);printf("基本工资:");scanf("%d",&temp.salary1);printf("职务工资:");scanf("%d",&temp.salary2);printf("津贴:");scanf("%d",&temp.salary3);wo[Number++]=temp; //写入到数组bc(&temp); //写入到文件}printf("添加成功\n");}//查看职工信息void see(){int i=0;printf("以下是全部职工\n");printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");while(i<Number){printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);i++;}}//查找职工信息void search(){int n=0;printf("1 按姓名查找\n");printf("2 按工号查找\n");scanf("%d",&n);switch(n){case 1: xmcz();break;case 2: ghcz();break;default: printf("输入错误!\n");break;}}void xmcz()//按姓名查找{char name[30];int i=0;printf("请输入要查找职工姓名:");scanf("%s",name);system("cls");printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");for (i=0;i<Number;i++){if (strcmp(name,wo[i].name)==0){printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);}}}void ghcz()//按工号查找{char id[10];int i=0;printf("请输入要查找职工工号:");scanf("%s",id);system("cls");printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");for (i=0;i<Number;i++){if (strcmp(id,wo[i].ID)==0){printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);}}}//删除职工信息void del(){int n=0;printf("1 按姓名删除\n");printf("2 按工号删除\n");scanf("%d",&n);switch(n){case 1: xmsc();break;case 2: ghsc();break;}}void xmsc()//按姓名删除{FILE *fp=NULL;char name[30];int i=0;int j=0;printf("请输入要删除的职工姓名:");scanf("%s",name);for(i=0;i<Number;i++){if (strcmp(name,wo[i].name)==0){for (j=i;j<Number-1;j++){wo[j]=wo[j+1];}Number--;}}//将剩余数据写入文件擦除以前的数据fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp); }fclose(fp);printf("删除成功;\n");}void ghsc()//按工号删除{FILE *fp=NULL;char id[60];int i=0;int j=0;printf("请输入要删除的职工工号:");scanf("%s",id);for(i=0;i<Number;i++){if (strcmp(id,wo[i].ID)==0){for (j=i;j<Number-1;j++){wo[j]=wo[j+1];}Number--;}}//将剩余数据写入文件擦除以前的数据fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp);}fclose(fp);printf("删除成功;\n");}//统计职工工资void statistics(){int i=0;double s=0.0;double sum[100];for(i=0;i<Number;i++){sum[i]=wo[i].salary1+wo[i].salary2+wo[i].salary3; printf("%s的总工资为:%f\n",wo[i].name,sum[i]); }for(i=0;i<Number;i++){s+=sum[i];}printf("平均工资为:%f\n",s/Number);}//修改职工信息void modify(){int mode=0;printf("请选择修改查找方式\n");printf("1 按姓名查找修改\n");printf("2 按工号查找修改\n");scanf("%d",&mode);switch(mode){case 1: xmxg();break;case 2: ghxg();break;default: printf("输入错误!\n");break;}}void xmxg()//按姓名修改{FILE *fp=NULL;char name[30];int i=0;printf("请输入要修改的职工姓名:");scanf("%s",name);for (i=0;i<Number;i++){if (strcmp(name,wo[i].name));elsebreak;}printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);printf("请重新输入该职工信息");printf("姓名:");scanf("%s",wo[i].name);printf("工号:");scanf("%s",wo[i].ID);printf("基本工资:");scanf("%d",&wo[i].salary1);printf("职务工资:");scanf("%d",&wo[i].salary2);printf("津贴:");scanf("%d",&wo[i].salary3);//信息修改后重新更新文件里面的数据以保持数据一致性fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp);}fclose(fp);}void ghxg()//按工号修改{FILE *fp=NULL;char id[30];int i=0;printf("请输入要修改的职工工号:");scanf("%s",id);for (i=0;i<Number;i++){if (strcmp(id,wo[i].ID));elsebreak;}printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);printf("请重新输入该职工信息");printf("姓名:");printf("姓名:");scanf("%s",wo[i].name);printf("工号:");scanf("%s",wo[i].ID);printf("基本工资:");scanf("%d",&wo[i].salary1);printf("职务工资:");scanf("%d",&wo[i].salary2);printf("津贴:");scanf("%d",&wo[i].salary3);//信息修改后重新更新文件里面的数据以保持数据一致性fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp);}fclose(fp);printf("\t=======>修改成功\n");}//保存数据void reserve(){printf("\t=====程序在运行时已自动保存.....\n");}void back(){printf("\t===>按Enter键返回主菜单\n");}//作者信息void author(){printf("\t***☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆***\n\n"); printf("\t^^^^^^^^^^^^^^^学校名称^^^^^^^^^^^^^\n\n"); printf("\t^^^^^^^^^^^^^^学院班级^^^^^^^^^^^^^\n\n"); printf("\t^^^^^^^^^^^^^^^XXX制作^^^^^^^^^^^^^\n\n"); printf("\t***★★★★★★★★★★★★★★★★***\n\n");。

C工资管理系统源代码

C工资管理系统源代码

C工资管理系统源代码Newly compiled on November 23, 2020#include <>#include <>#include <>#include <>#include <>#define TITLE "\n 月份工号姓名应发工资各种折扣实发工资\n" #define DATA " %2d %4ld %-10s % % %\n",p1->month,p1->num,p1->name,p1->should_pay,p1->rebate,p1->actual_paytypedef struct pay{long num;short month;char name[20];float gw,jn,zw,zl,jt,yj;float should_pay;float fz,gj,sd,others;float rebate;float actual_pay;struct pay *next;}PAY;FILE *fp;PAY *p1=NULL,*p2=NULL,*head=NULL;void menu();PAY *input();void output();void save(PAY *head);PAY *open();PAY *insert();void search();PAY *del();PAY *revise();/*主程序模块*/void main(void){short sel;do{menu();scanf("%d",&sel);switch(sel){case 1:head=input(); 建工资档案\n");printf("\t\t\t\t2.新增工资信息\n");printf("\t\t\t\t3.修改工资信息\n");printf("\t\t\t\t4.删除工资信息\n");printf("\t\t\t\t5.查找工资信息\n");printf("\t\t\t\t6.分类信息列表\n");printf("\t\t\t\t7.保存信息\n");printf("\t\t\t\t0.退出\n");printf("\n\n\n\n\n\n\n\n");}/*输入模块*/PAY *input(){short n=1;p1=(PAY*)malloc(sizeof(PAY));if(p1==NULL){printf("内存不足,无法创建链表!");getch();}printf("\n请输入第%d位职工的信息(以工号为0结束):\n",n); printf(" 工号:");scanf("%d",&p1->num);if(p1->num==0){printf("按任意键返回!");getch();free(p1);return 0;}getchar();printf(" 姓名:");gets(p1->name);printf(" 工资月份:");scanf("%d",&p1->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);p1->should_pay=p1->gw+p1->jn+p1->zw+p1->zl+p1->jt+p1->yj;p1->rebate=p1->fz+p1->gj+p1->sd+p1->others;p1->actual_pay=p1->should_pay-p1->rebate;while(p1!=NULL){if(n==1)head=p1;elsep2->next=p1;n++;p2=p1;p1=(PAY*)malloc(sizeof(PAY));if(p1==NULL){printf("内存不足,无法创建链表!");getch();}printf("请输入第%d位职工的信息(以工号为0结束):\n",n);printf(" 工号:");scanf("%d",&p1->num);getchar();if(p1->num==0){p1=NULL;break;}printf(" 姓名:");gets(p1->name);printf(" 工资月份:");scanf("%d",&p1->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);p1->should_pay=p1->gw+p1->jn+p1->zw+p1->zl+p1->jt+p1->yj;p1->rebate=p1->fz+p1->gj+p1->sd+p1->others;p1->actual_pay=p1->should_pay-p1->rebate;}p2->next=NULL;部清单\n");printf("\t\t2.按月输出\n");printf("\t\t3.按工资段输出\n");printf("\t\t0.返回\n");scanf("%d",&sel);}while(sel!=1&&sel!=2&&sel!=3&&sel!=0);head=open();if(head==NULL)return;elseswitch(sel){case 1:printf("\n\t\t\t ******全部清单******\n");printf(TITLE);p1=head;do{printf(DATA);p1=p1->next;}while(p1!=NULL);break;flag=0;printf("输入要查的月份:");scanf("%d",&month);printf("\n\t\t\t******第%d月工资清单******\n",month); printf(TITLE);p1=head;do{if(p1->month==month){printf(DATA);p1=p1->next;flag=1;}elsep1=p1->next;}while(p1!=NULL);if(flag==0)printf("没有该月清单\n");break;case 3:flag=0;printf("输入最低工资:");scanf("%f",&min);printf("输入最高工资:");scanf("%f",&max);printf("\n\t\t ******%到%工资的名单******\n",min,max); printf(TITLE);p1=head;do{if(p1->actual_pay>min&&p1->actual_pay<max){printf(DATA);p1=p1->next;flag=1;}p1=p1->next;}while(p1!=NULL);if(flag==0)printf("没有该工资段的职工\n"); break;case 0:break;}}while(sel!=0);}/*保存文件*/void save(PAY *head){short write;fp=fopen("","w");if(fp==NULL){printf("创建文件失败!");getch();return;}p1=p2=head;while(p1!=NULL){write=fwrite(p1,sizeof(PAY),1,fp); if(!write){printf("无法写入文件!");getch();return;}p1=p1->next;}fclose(fp);printf("成功存盘!");getch();}/*打开文件*/PAY *open(){short n=1,read;fp=fopen("","r");if(fp==NULL){printf("无法打开档案文件!");getch();return NULL;}if((p1=p2=(PAY*)malloc(sizeof(PAY)))==NULL) {printf("内存不足!");getch();return NULL;}read=fread(p1,sizeof(PAY),1,fp);if(!read){printf("文件读取出错!1");getch();return NULL;}if(p1->next==NULL)head=p1;else{do{if(n==1)head=p1;elsep2->next=p1;n++;p2=p1;if((p1=(PAY*)malloc(sizeof(PAY)))==NULL) {printf("内存不足!");getch();return NULL;}read=fread(p1,sizeof(PAY),1,fp);if(!read){printf("文件读取出错!2");getch();return NULL;}}while(p1->next!=NULL);p2->next=p1;}return head;fclose(fp);}/*插入模块*/PAY *insert(){PAY *p3=NULL;char sel;head=open();if(head==NULL)return NULL;elsedo{printf("请输入要插入的职工信息:\n"); p3=(PAY*)malloc(sizeof(PAY));if(p3==NULL){printf("内存不足,无法创建链表!"); getch();}printf(" 工号:");scanf("%d",&p3->num);getchar();printf(" 姓名:");gets(p3->name);printf(" 工资月份:");scanf("%d",&p3->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p3->gw,&p3->jn,&p3->zw,&p3->zl,&p3->jt,&p3->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p3->fz,&p3->gj,&p3->sd,&p3->others);p3->should_pay=p3->gw+p3->jn+p3->zw+p3->zl+p3->jt+p3->yj;p3->rebate=p3->fz+p3->gj+p3->sd+p3->others;p3->actual_pay=p3->should_pay-p3->rebate;p1=head;while(p1!=NULL){p2=p1;p1=p1->next;}p2->next=p3;p3->next=NULL;printf("成功插入,是否继续是(Y)否(N)\n");sel=getch();}while(sel=='Y'||sel=='y');printf("\n任意键返回,并存盘……\n");getch();return head;}/*查找模块*/void search(){short sel;long num;char name[20],choose;head=open();if(head==NULL)return;elsedo{doprintf("\n选择查找方式:\n");printf("\t\t1.按工号查找\n");printf("\t\t2.按姓名查找\n");scanf("%d",&sel);getchar();}while(sel!=1&&sel!=2);switch(sel){case 1:printf("输入要查的工号:");scanf("%ld",&num);break;case 2:printf("输入要查的姓名:");gets(name);break;}p1=head;while((p1->next!=NULL)&&(p1->num!=num)&&(strcmp(p1->name,name)!=0)) 工号删除\n");printf("\t\t2.按姓名删除\n");scanf("%d",&sel);getchar();}while(sel!=1&&sel!=2);switch(sel){case 1:printf("输入要删除的工号:");scanf("%ld",&num);break;case 2:printf("输入要删除的姓名:");gets(name);break;p1=head;if((p1->num==num)||strcmp(p1->name,name)==0){head=p1->next;printf("删除信息成功!");}else{while((p1->next!=NULL)&&(p1->num!=num)&&(strcmp(p1->name,name)!=0)) {p2=p1;p1=p1->next;}if((p1->num==num)||strcmp(p1->name,name)==0){p2->next=p1->next;free(p1);printf("\n删除信息成功!\n");}elseprintf("\n没有该信息!\n");}printf("是否继续是(Y)否(N)\n");choose=getch();}while(choose=='Y'||choose=='y');printf("任意键返回,并存盘……");getch();return head;}/*修改模块*/PAY *revise(){short sel;long num;char name[20],choose;head=open();if(head==NULL)return NULL;elsedo{do{printf("\n查找要修改的对象:\n");printf("\t\t1.按工号查找\n");printf("\t\t2.按姓名查找\n");scanf("%d",&sel);getchar();}while(sel!=1&&sel!=2);switch(sel){case 1:printf("输入要查的工号:");scanf("%ld",&num);break;case 2:printf("输入要查的姓名:");gets(name);break;}p1=head;while((p1->next!=NULL)&&(p1->num!=num)&&(strcmp(p1->name,name)!=0)) //用成p1!=NULL有问题p1=p1->next;if((p1->num==num)||strcmp(p1->name,name)==0){printf("您要修改的原始信息如下:\n");printf(TITLE);printf(DATA);printf("\n将上述信息改为如下信息:\n");printf(" 工号:");scanf("%d",&p1->num);getchar();printf(" 姓名:");gets(p1->name);printf(" 工资月份:");scanf("%d",&p1->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);p1->should_pay=p1->gw+p1->jn+p1->zw+p1->zl+p1->jt+p1->yj;p1->rebate=p1->fz+p1->gj+p1->sd+p1->others;p1->actual_pay=p1->should_pay-p1->rebate;}elseprintf("你要修改的信息不存在!\n");printf("是否继续是(Y)否(N)\n");choose=getch();}while(choose=='Y'||choose=='y');printf("任意键返回,并存盘……");getch();return head;}。

C工资管理系统源代码

C工资管理系统源代码
case 3:
head=revise(); //修改模块
break;
case 4:
head=del(); //删除模块
break;
case 5:
search(); //查找模块
break;
case 6:
output(); //输出模块
break;
case 7:
save(head); //保存模块
break;
do
{
if(p1->actual_pay>min&&p1->actual_pay<max)
{
printf(DATA);
p1=p1->next;
flag=1;
}
else
p1=p1->next;
}while(p1!=NULL);
if(flag==0)
printf("没有该工资段的职工\n");
break;
p1->actual_pay=p1->should_pay-p1->rebate;
while(p1!=NULL)
{
if(n==1)
head=p1;
else
p2->next=p1;
n++;
p2=p1;
p1=(PAY*)malloc(sizeof(PAY));
if(p1==NULL)
{
printf("内存不足,无法创建链表!");
scanf("%d",&p1->month);
printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");

C工资管理系统源代码

C工资管理系统源代码
}
/*插入模块*/
PAY *insert()
{
PAY *p3=NULL;
char sel;
head=open();
if(head==NULL)
return NULL;
else
do
{
printf("请输入要插入的职工信息:\n");
p3=(PAY*)malloc(sizeof(PAY));
if(p3==NULL)
C工资管理系统源代码
#include <>
#include <>
#include <>
#include <>
#include <>
#define TITLE "\n月份工号姓名应发工资各种折扣实发工资\n"
#define DATA " %2d %4ld %-10s % % %\n",p1->month,p1->num,p1->name,p1->should_pay,p1->rebate,p1->actual_pay
scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);
printf("房租扣款,公积金,水电费,其它扣款:\n");
scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);

C++职工工资管理系统源代码

C++职工工资管理系统源代码

附录〈源程序〉#i nclude <stdio.h>#i nclude <stdlib.h>#in elude <stri ng.h>struct worker{char n ame[30];char ID[10];int salary1,salary2,salary3;};int dq(struct worker wo[]);void show();void bc(struct worker wo[]);void add();void see();void search();void ghcz();void xmcz();void del();void xmsc();void ghsc();void statistics();void modify。

;void ghxg();void xmxg();void reserve();void back();void author();struct worker wo[100]; // 保存所有的职工信息int Number=0; // 记录总的职工人数void mai n(){int choose=0;while(true){show();prin tf("\t\t====> 请选择:”);sca nf("%d",&choose);system("cls");switch(choose){case 0: exit(O);// 退出break;case 1: add();back();〃添加职工信息break;case 2: see();back();〃查看职工信息break;case 3: search();back();〃查找职工信息break;case 4: del();back();〃删除职工信息break;case 5: statistics。

c语言职工工资管理系统代码

c语言职工工资管理系统代码

c语言职工工资管理系统代码随着社会的发展和经济的进步,职工工资管理成为了企业管理中的重要一环。

为了提高工资管理的效率和准确性,许多企业开始采用计算机软件来进行工资管理。

本文将介绍一个基于C语言的职工工资管理系统代码。

首先,我们需要定义一些基本的数据结构和变量。

在这个系统中,我们需要记录每个职工的姓名、工号、基本工资、津贴、扣款等信息。

我们可以使用结构体来定义这些信息,例如:```cstruct Employee {char name[20];int id;float basicSalary;float allowance;float deduction;};```接下来,我们可以定义一些函数来实现不同的功能。

例如,我们可以编写一个函数来添加新的职工信息:```cvoid addEmployee(struct Employee *employees, int *count) { printf("请输入职工姓名:");scanf("%s", employees[*count].name);printf("请输入职工工号:");scanf("%d", &employees[*count].id);printf("请输入职工基本工资:");scanf("%f", &employees[*count].basicSalary);printf("请输入职工津贴:");scanf("%f", &employees[*count].allowance);printf("请输入职工扣款:");scanf("%f", &employees[*count].deduction);(*count)++;}```我们还可以编写一个函数来计算每个职工的实际工资:```cfloat calculateSalary(struct Employee employee) {return employee.basicSalary + employee.allowance - employee.deduction;}```接下来,我们可以编写一个函数来显示所有职工的信息和实际工资:```cvoid displayEmployees(struct Employee *employees, int count) {printf("姓名\t工号\t基本工资\t津贴\t扣款\t实际工资\n");for (int i = 0; i < count; i++) {printf("%s\t%d\t%.2f\t\t%.2f\t%.2f\t%.2f\n", employees[i].name, employees[i].id, employees[i].basicSalary, employees[i].allowance, employees[i].deduction, calculateSalary(employees[i]));}}```最后,我们可以编写一个主函数来实现整个系统的流程:```cint main() {struct Employee employees[100];int count = 0;int choice;do {printf("请选择操作:\n");printf("1. 添加职工信息\n");printf("2. 显示职工信息\n");printf("3. 退出\n");scanf("%d", &choice);switch (choice) {case 1:addEmployee(employees, &count);break;case 2:displayEmployees(employees, count);break;case 3:printf("感谢使用职工工资管理系统!\n"); break;default:printf("无效的选择,请重新输入!\n");break;}} while (choice != 3);return 0;}```通过以上代码,我们可以实现一个简单的职工工资管理系统。

数据结构课程设计-职工信息管理系统-单链表实现程序源代码

数据结构课程设计-职工信息管理系统-单链表实现程序源代码

printf(”请你输入要查找的工号:");
scanf(”%s",findmess);
p=Locate(l,findmess,”num”);
if(p)

printf(”\t\t\t\t查找结果\n”);
printstart(); //打印横线
printc(); //打印各学科标题
printe(p); //打印p结点各个数据成员的值
printf(”\t* [7] 排序 [8] 保存职工信息 *\n");
printf(”\t* [9] 显示数据 [0] 退出系统 *\n”);
printf(”\t* *\n”);
printf("\t*****************************************************************\n”);

void Wrong()

printf("\n=====>提示:输入错误!\n");

void Nofind()

printf("\n=====〉提示:没有找到该职工!\n”);

void printc() /* 本函数用于输出中文 */
{
printf(" 工号\t 姓名 性别 部门 职称 工资 总工资 平均工资\n");
Node *p,*r; /*实现删除操作的临时的结构体指针变量*/
char findmess[20];
if(!l—〉next) //当list无后继结点时,提示和结束返回del()

printf("\n=====>提示:没有记录可以删除!\n");

c语言职工工资管理系统代码

c语言职工工资管理系统代码

c语言职工工资管理系统代码
(实用版)
目录
1.引言
2.系统功能介绍
3.系统设计与实现
4.系统测试与验证
5.总结
正文
一、引言
随着社会的快速发展,职工工资管理系统已经成为企事业单位不可或缺的一部分。

本文将介绍一个基于 C 语言编写的职工工资管理系统代码,以满足企事业单位对职工工资管理的需求。

二、系统功能介绍
该职工工资管理系统主要包括以下功能:
1.员工信息管理:用于添加、修改和删除员工的基本信息,如姓名、工号、性别、出生日期、职位、电话等。

2.工资信息管理:用于录入、修改和删除员工的工资信息,包括基本工资、绩效工资、奖金、扣款等。

3.查询功能:提供按工号、姓名、职位等多种条件查询员工信息及工资信息。

4.打印功能:支持打印员工工资单。

三、系统设计与实现
本系统采用 C 语言编写,利用结构体和文件操作实现员工信息和工资信息的存储和管理。

系统主要包括以下几个模块:
1.数据结构设计:定义员工结构体和工资结构体,用于存储员工信息和工资信息。

2.文件操作:实现员工信息和工资信息的存储和读取,采用文件存储数据,确保数据安全性。

3.功能模块:实现员工信息管理、工资信息管理、查询和打印功能。

四、系统测试与验证
为确保系统的正确性和可靠性,对系统进行了详细测试。

测试结果表明,本系统能够正确处理各种操作,满足用户需求。

五、总结
本文介绍了一个基于 C 语言编写的职工工资管理系统代码。

该系统具有简单易用、功能齐全、安全性高等特点,可满足企事业单位对职工工资管理的需求。

C语言职工管理系统源代码及运行截图(简单版)

C语言职工管理系统源代码及运行截图(简单版)

#include<stdio.h>#include<string.h>#define N 100typedef struct worker{char name[20];long number;int y,m,d;char zhicheng[20];char bumen[20];float salary;}Worker;void Display(){printf("\n\n\n\t\t***************职工管理系统*************\n\n");printf("\t\t\t0.退\t\t 出\n");printf("\t\t\t1.新\t\t 建\n");printf("\t\t\t2.显\t\t 示\n");printf("\t\t\t3.查\t\t 询\n");printf("\t\t\t4.删\t\t 除\n\n");}/*******1.新建**********/void Add( Worker w[],int n){int i;printf("\t姓名\t工号\t进场时间\t职称\t部门\t工资\n\n");for(i=0;i< n;i++){printf("员工%d: ",i+1);scanf("%s %ld %d %d %d %s %s %f",w[i].name,&w[i].number, &w[i].y,&w[i].m,&w[i].d,w[i].zhicheng,w[i].bumen,&w[i].salary);}}/*******2.显示**********/void Browse( Worker w[],int n ){int i;printf("\t姓名\t工号\t进场时间\t职称\t部门\t工资\n\n");for(i=0;i< n;i++){printf("员工%d:",i+1);printf("%s\t%ld\t%d-%d-%d\t%s\t%s\t%f\n\n",w[i].name,w[i].number,w[i].y,w[i].m, w[i].d,w[i].zhicheng,w[i].bumen,w[i].salary);}}/*******3.1查询姓名**********/void SearchName( Worker w[],int n ){char name[20];int i;printf("\t\t\t输入要查询的名字:");scanf("%s",name);for( i = 0; i < n; i ++ ){if( strcmp( w[i].name,name ) == 0 ){printf("\n\t\t\t查得信息如下:\n\n");printf("姓名\t工号\t进场时间\t职称\t部门\t工资\n\n");printf("%s\t%ld\t%d-%d-%d\t%s\t%s\t%f\n\n",w[i].name,w[i].number,w[i].y,w[i].m,w[i].d,w[i].zhicheng,w[i].bumen,w[i].salary);return;}}printf("\t\t\t查无此人!");}/*******3.2查询工号**********/void SearchNumber( Worker w[],int n ){long number;int i,k=0;printf("\t\t\t输入要查询的工号:");scanf("%ld",&number);for( i = 0; i < n; i ++ ){if( w[i].number == number ){printf("\n\t\t\t查得信息如下:\n\n");printf("姓名\t工号\t进场时间\t职称\t部门\t工资\n\n");printf("%s\t%ld\t%d-%d-%d\t%s\t%s\t%f\n\n",w[i].name,w[i].number,w[i].y,w[i].m, w[i].d,w[i].zhicheng,w[i].bumen,w[i].salary);return;}}printf("\n\t\t\t查无此人!");}/*******3.查询**********/void Search( Worker w[],int n ){int x;printf("\t\t\t选择查询方式(1.姓名/2.工号):");scanf("%d",&x);printf("\n");switch(x){case 1:SearchName(w,n);break;case 2:SearchNumber(w,n);break;}}/*******4.删除**********/void Delete( Worker w[],int n ){char name[20];int i,j;printf("\t\t\t输入要删除的名字:");scanf("%s",name);printf("\n");for( i = 0; i < n; i ++ ){if( strcmp( w[i].name,name ) == 0 ){printf("\t\t\t将删除以下信息:\n\n");printf("\t姓名\t工号\t进场时间\t职称\t部门\t工资\n\n");printf("\t%s\t%ld\t%d-%d-%d\t%s\t%s\t%f\n\n",w[i].name,w[i].number,w[i].y,w[i]. m,w[i].d,w[i].zhicheng,w[i].bumen,w[i].salary);for( j = i;j<n-1;j++ ){w[j] = w[j+1];}printf("\t\t\t成功删除!\n\n");return;}}printf("\t\t\t查无此人!");}void Run( Worker w[],int n ){int choice;do{Display();printf("\t\t\t输入你的选择:");scanf("%d",&choice);printf("\n");switch( choice ){case 0:break;case 1:Add(w,n);break;case 2:Browse(w,n);break;case 3:Search(w,n);break;case 4:Delete(w,n);n--;break;}}while(choice);}void main(){int n;Worker w[N];printf("\t输入职员个数:");scanf("%d",&n);Run(w,n);}友情提示:范文可能无法思考和涵盖全面,供参考!最好找专业人士起草或审核后使用,感谢您的下载!。

C语言课程设计职工工资信息管理系统源代码

C语言课程设计职工工资信息管理系统源代码

#include <stdio.h>#include <string.h>#include <stdlib.h>#include <conio.h>#define N 10000int choice;struct employee{int num;int position;char name[10000];char sex[2];int salary;int i,max,t;}em[N];struct empsalary{char name[10000];int salary;}emps[N];void manage();void query();void input();void display();void change();void del();void add();void paixu();int changeposition();int changesalary();void querysalary();void creat();void main(){do{printf("欢迎进入职工管理系统中文版\n"); printf("请你选择操作类型:\n");printf("1进入管理系统\n");printf("2进入查询系统\n");printf("0退出系统\n");scanf("%d",&choice);switch(choice){case 1:manage();break;case 2:query();break;case 0:{printf("谢谢使用,再见\n");exit(0);}default:{printf("输入有错误请重新输入:\n");return;}}}while(1);}void manage(){int choicemanage;char choice='y';while(choice=='y'||choice=='Y'){printf("欢迎进入管理系统\n");printf("请你选择操作类型:\n");printf("1输入职工信息\n");printf("2显示职工信息\n");printf("3修改职工信息\n");printf("4追加一个职工信息\n");printf("5删除一个职工信息\n");printf("6排序\n");printf("0返回\n");scanf("%d",&choicemanage);switch(choicemanage){case 1:input();break;case 2:display();break;case 3:change();break;case 4:add();break;case 5:del();case 6:paixu();break;case 0:printf("谢谢你的使用再见\n");return;default:printf("你的输入有错请重新输入\n"); }printf("是否继续管理?(y/n)");scanf("%s",&choice);}if(toupper(choice)=='N'||(choice)=='n'){printf("输入完毕,任意键返回\n");getch();return;}}void input(){FILE *fp;int i=0;char choiceinput='y';if((fp=fopen("employee.txt","w"))==NULL) return;while(choiceinput=='y'||choiceinput=='Y'){i++;printf("第%d个职工\n",i);printf("\n");printf("请你输入工号:\n");scanf("%d",&em[i].num);printf("\n");printf("请你输入职位:\n");printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");scanf("%d",&em[i].position);printf("\n");printf("请你输入姓名:\n");scanf("%s",em[i].name);printf("\n");printf("请你输入性别以m为男f为女:\n");scanf("%s",em[i].sex);printf("\n");printf("请你输入工资:\n");scanf("%d",&em[i].salary);printf("\n");printf("是否继续输入?(y/n)\n");scanf("%s",&choiceinput);fwrite(&em[i],sizeof(struct employee),1,fp);}if(toupper(choiceinput)=='N'){fclose(fp);printf("输入完毕,任意键返回\n");getch();return;}}void display(){FILE *fp;int i;if((fp=fopen("employee.txt","r"))==NULL)return;printf("输出结果:\n");for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {printf("工号%d\n",em[i].num);printf("职位为%d\n",em[i].position);printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name);printf("性别为%s\n",em[i].sex);printf("其中m为男f为女\n");printf("工资为%d\n",em[i].salary);}printf("完毕按任意键返回\n");getch();fclose(fp);return;}void change(){FILE *fp;int i;char chname[8];int choicechange;printf("请你输入要修改的人的姓名:\n");scanf("%s",&chname);if((fp=fopen("employee.txt","w+"))==NULL){printf("不能够打开这个文件\n");return;}for(i=0;i<N;i++){if(strcmp(chname,em[i].name)==0){printf("这是你要修改的人的信息\n");printf("工号为%d\n 职位为%d\n 姓名为%s\n 性别为%s\n 工资为%d\n",em[i].num,em[i].position,em[i].name,em[i].sex,em[i].salary);printf("请你输入要修改的部分:\n");printf("1修改职位\n");printf("2修改工资\n");printf("0退出系统\n");printf("请选择\n");scanf("%d",&choicechange);switch(choicechange){case 1:em[i].position=changeposition();break;case 2:em[i].salary=changesalary();break;case 0:return;default :printf("输入有错误");}fwrite(&em[i],sizeof(struct employee),1,fp); }}fclose(fp);printf("操作完成按任意键返回\n");getch();return;}int changeposition(){int newposition;printf("请你输入新职位:\n");printf("1董事长2总经理3副总经理\n"); printf("4经理5副经理6秘书\n"); printf("7技术员8领班9员工\n"); scanf("%d",&newposition);return(newposition);}int changesalary(){int newsalary;printf("请你输入新的工资:\n");scanf("%d",&newsalary);return(newsalary);}void add(){struct employee emp;FILE *fp;int i=0;if((fp=fopen("employee.txt","ab+"))==NULL){printf("不能够打开这个文件\n");getch();return;}printf("请你输入新人的内容:\n");printf("请你输入工号:\n");scanf("%d",&em[i].num);printf("请你输入职位:\n");printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");scanf("%d",&emp.position);printf("请你输入姓名:\n");scanf("%s",);printf("请你输入性别以m为男f为女:\n");scanf("%s",emp.sex);printf("请你输入工资:\n");scanf("%d",&emp.salary);fwrite(&emp,sizeof(struct employee),1,fp);rewind(fp);printf("插入完毕,按任意键返回\n");getch();fclose(fp);return;}void del(){int i=0;char delname[8];FILE *fp;if((fp=fopen("employee.txt","w"))==NULL){printf("文件为空,不能够打开\n");printf("按任意键返回\n");getch();return;}printf("请你输入要删除的人的姓名:\n");scanf("%s",delname);for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {if(strcmp(em[i].name,delname)!=0)fwrite(&em[i],sizeof(struct employee),1,fp);}fclose(fp);if((fp=fopen("employee.txt","r"))==NULL)return;printf("新的职工的信息为:\n");for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {printf("工号%d",em[i].num);printf("职位为%d",em[i].position);printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name[8]);printf("性别为%s\n",em[i].sex[2]);printf("其中m为男f为女\n");printf("工资为%d\n",em[i].salary);fclose(fp);}}void query(){FILE *fp;int i=0;char quename[8];if((fp=fopen("employee.txt","r"))==NULL){printf("不能够打开文件,按任意键返回\n");getch();return;}printf("请你输入要查询的人的姓名\n");scanf("%s",quename);for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {if(strcmp(em[i].name,quename)==0){printf("\t\t\n查询到的职工号或姓名为的信息如下:\n");printf("以下是你要查询的人的信息\n");printf("工号%d",em[i].num);printf("职位为%d",em[i].position);printf("\t 1董事长2总经理3副总经理\n");printf("\t 4经理5副经理6秘书\n");printf("\t 7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name);printf("性别为%s\n",em[i].sex);printf("\t其中m为男f为女\n");printf("工资为%d\n",em[i].salary);printf("\n");printf("查询完毕,按任意键返回\n");getch();fclose(fp);return;}}printf("没有这样的人,按任意键返回\n");getch();fclose(fp);return;}void querysalary(){int i;FILE *fp1,*fp2;creat();if((fp1=fopen("employee.txt","w+"))==NULL)return;for(i=0;fread(&em[i],sizeof(struct employee),1,fp1)!=0;i++) {printf("输出结果为:\n");printf("工号%d",em[i].num);printf("职位为%d",em[i].position);printf(" 1董事长2总经理3副总经理\n");printf(" 4经理5副经理6秘书\n");printf(" 7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name[8]);printf("性别为%s\n",em[i].sex[2]);printf("其中m为男f为女\n");printf("工资为%d\n",em[i].salary);strcpy(emps[i].name,em[i].name);emps[i].salary=em[i].salary;}if((fp2=fopen("empsalary.txt","w"))==NULL)return;for(i=0;i<N;i++)fwrite(&emps[i],sizeof(struct empsalary),1,fp2);fclose(fp1);fclose(fp2);}void creat(){FILE *fp;if((fp=fopen("D:\\employee.txt","w+"))==NULL)return;input();fclose(fp);}void paixu(){int max,i,t,j;for(i=1;i<10;i++){max=em[i].salary;for(j=i;j<10;j++){if(em[j].salary>max){max=em[j].salary;t=em[j].salary;em[j].salary=t;}}}printf("姓名工资工号性别职位\n");for(i=1;i<10;i++)printf(" %s %d %d %s %d\n ",em[i].name,em[i].salary,em[i].num,em[i].sex,em[i].position);}。

c语言课程设计职工工资管理系统源代码word文档

c语言课程设计职工工资管理系统源代码word文档

绝对可以完美运行,下面有运行图片#include<stdio.h> //调用库函数#include<string.h> //字符串处理#include<conio.h> //控制台输入输出#include<stdlib.h> //定义杂项函数及内存分配函数#define N 2 //宏定义以3代替N/******************************************************************************函数声明*******************************************************************************/ void enter();int menu();void input();void output();void search();void search_employeeid();void search_name();void edit();void array();void array_basesalary();void array_postwage();void array_totalwage();void statistics();void save();void load();/******************************************************************************职工类型定义*******************************************************************************/ struct employee{char employeeid[10];char name[10];char sex[10];int age;float basesalary;float postwage;float totalwage;};/******************************************************************************职工变量定义******************************************************************************/ struct employee emp[N];struct employee replace;struct employee *p=emp;/*****************************************************************************系统主函数******************************************************************************/ void main(){int c;while(1){printf(" \n\n\n\n"); printf(" 欢迎进入职工工资管理系统 \n\n\n");printf(" 1 进入管理系统 \n\n");printf(" 0 退出 \n\n");printf(" \n\n\n\n");printf(" 请输入你选择: \n");scanf("%d",&c);switch(c){case 1:enter();break;case 0:printf(" 谢谢使用!\n");exit(0);}}}/*****************************************************************************功能:登陆函数,进行密码验证*****************************************************************************/ void enter(){char q;char key[10],password[10]="china";int k=1,i;printf(" 请输入密码: \n");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}while(k<=3){if(strncmp(key,password,5)==0){while(1){int a;//system("cls");a=menu();switch(a){case 1:input();break;case 2:output();break;case 3:search();break;case 4:edit();break;case 5:array();break;case 6:load();statistics();break;case 0:printf("\n\n 谢谢使用!\n\n\n\n");save();exit(0);}}}else{k++;printf(" 输入密码错误!请再次输入:");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}if(k>2){if(strncmp(password,key,5)==0)continue;else{printf(" 输入密码错误三次,系统将自动退出!\n");exit(0);}}}}}/************************************************************************功能: 主菜单函数参数:a类型:int说明: 变量返回值: a************************************************************************/int menu(){int a ;printf("\n\n");printf("|*****************欢迎进入职工工资管理系统************************|\n");printf("| |\n");printf("| |\n");printf("| 1 职工信息输入|\n");printf("| |\n");printf("| 2 职工信息输出|\n");printf("| |\n");printf("| 3 职工信息查询|\n");printf("| |\n");printf("| 4 职工信息修改|\n");printf("||\n");printf("| 5 工资排序|\n");printf("||\n");printf("| 6 工资统计|\n");printf("||\n");printf("| 0 退出|\n");printf("||\n");printf("||\n");printf("|*****************************************************************|\n");printf("\n\n");printf(" 请输入你所选择的选项:");scanf("%d",&a);while(a>6||a<0){printf(" error!\n");printf(" 请重新输入你所选择的选项:");scanf("%d",&a);}return a;}/********************************************************************************* ***功能:职工信息输入********************************************************************************** ***/void input(){int c;p=emp;printf(" 进入职工信息输入模块 \n\n\n");for(c=0;c<N;c++,p++){p[c].totalwage=p[c].basesalary+p[c].postwage;printf(" 请输入第%d个职工信息:\n\n",c+1);printf(" 请输入职工号:\n");scanf("%s",p->employeeid);if(strcmp(p->employeeid,"0")!=0){printf(" 请输入职工姓名:\n");scanf("%s",p->name);printf(" 请输入职工性别: \n");scanf("%s",&p->sex);printf(" 请输入职工年龄: \n");scanf("%d",&p->age);printf(" 请输入职工基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入职工岗位工资:\n");scanf("%f",&p->postwage);printf(" 职工信息输入完成! \n\n");}elsereturn;}save();}/*******************************************************************************功能:职工信息输出********************************************************************************/ void output(){int j;load();p=emp;printf(" 进入职工信息输出模块 \n\n\n");printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("-------------------------------------------------------------------------------\n");for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");}printf("\n\n 职工信息输出完成! \n\n");getchar();}/******************************************************************************功能:职工信息查询******************************************************************************/ void search(){int j;while(1){printf("*********************职工信息查询*********************\n\n\n");printf(" 1 按职工号查询 \n");printf(" 2 按职工姓名查询 \n");printf(" 0 退出该项操作 \n");printf("\n\n");while(1){printf(" 请输入你的选择 \n");scanf("%d",&j);if(j>=0&&j<=2){switch(j){case 1:search_employeeid();break;case 2:search_name();break;case 0:return;}}else{printf(" 输入错误! \n\n");printf(" 请再次输入你的选择:\n\n");}}}}/*******************************************************************************功能:按职工号查询函数*******************************************************************************/ void search_employeeid(){char employeeid[10];int k,j;p=emp;printf("*********************按职工号查询职工信息*****************************\n\n\n\n");printf(" 请输入要查询职工的职工号:\n\n");scanf("%s",employeeid);for(k=0;k<N;k++){if(strcmp(employeeid,p->employeeid)==0){j=k;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found\n");return;}}}/*****************************************************************************功能:按职工姓名查询函数*****************************************************************************/ void search_name(){char name[10];int flog=0;int f,j;p=emp;printf("******************************按职工姓名查询职工信息***********************\n\n\n");printf(" 请输入要查询职工的姓名:\n\n");scanf("%s",name);for(f=0;f<N;f++,p++){if(strcmp(name,p->name)==0){j=f;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found \n\n");return;}}getchar();}/*******************************************************************************功能:职工信息修改函数*******************************************************************************/ void edit(){char e[10];int g=0,j;char flog;p=emp;printf(" 请输入你要修改职工的职工号: \n");scanf("%s",e);for(g=0;g<N;g++){// if(*e==p[g].employeeid)if(strcmp(e,p->employeeid)==0){j=g;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资 |总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j]. name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");printf(" 是否要修改该职工信息?y(是)or n(否)?\n\n");getchar();scanf("%c",&flog);if(flog == 'y'){printf(" 请输入新姓名:\n");scanf("%s",p->name);printf(" 请输入性别: \n");scanf("%s",&p->sex);printf(" 请输入年龄: \n");scanf("%d",&p->age);printf(" 请输入基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入岗位工资:\n");scanf("%f",&p->postwage);printf(" 修改职工信息成功! \n\n");}if(flog == 'n'){printf(" 退出该项操作! \n\n");return;}save();}if(g==N){printf(" not found \n\n\n");return;}}}/************************************************************************功能:职工工资排列函数************************************************************************/void array(){int j;while(1){printf("*************************工资排序*********************\n\n"); printf(" 1 按基本工资排序 \n\n");printf(" 2 按岗位工资排序 \n\n");printf(" 3 按总工资排列 \n\n");printf(" 0 退出 \n\n");printf("\n\n\n");while(1){printf(" 请输入你的选择: \n\n");scanf("%d",&j);if(j>=0&&j<=3){switch(j){case 1:array_basesalary();break;case 2:array_postwage();break;case 3:array_totalwage();break;case 0:return;}}else{printf(" 输入错误!\n\n\n");printf(" 请再次输入你的选择:\n\n");}}}}/**************************************************************************功能:按基本工资排列(选择法)***************************************************************************/ void array_basesalary(){int i,j,k;p=emp;for(i=0;i<N-1;i++){k=i;for(j=i+1;j<N;j++){if(p[k].basesalary<p[j].basesalary)k=j;}if(k!=i){replace=emp[k];emp[k]=emp[i];emp[i]=replace;}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按岗位工资排列(冒泡法)*************************************************************************/void array_postwage(){int i,j;p=emp;for(i=0;i<N;i++){for(j=0;j<N-i;j++){if(p[j].postwage<p[j+1].postwage){replace=emp[j];emp[j]=emp[j+1];emp[j+1]=replace;}}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 |年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按总工资排列(插入法)************************************************************************/void array_totalwage(){int i,j;p=emp;for(i=1;i<N;i++){replace=emp[i];for(j=i-1;j>=0&&p[i].totalwage>p[i].totalwage;j--){emp[j+1]=emp[j];emp[j+1]=replace;}}for(j=N-1;j>=0;j--){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号 |姓名 |性别 | 年龄 |基本工资 |岗位工资|总工资 |\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid, p[j].name,p[j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/*************************************************************************功能:工资统计函数**************************************************************************/void statistics(){int z,a=0,b=0,c=0;p=emp;for(z=0;z<N;z++){if(p[z].totalwage>3000){a++;continue;}if(p[z].totalwage>=2000&&p[z].totalwage<=3000){b++;continue;}if(p[z].totalwage<=2000&&p[z].totalwage>0){c++;continue;}}printf(" 总工资在3000元以上的职工人数有: %d\n\n",a);printf(" 总工资在2000元至3000元的职工人数有:%d\n\n",b);printf(" 总工资在2000元以下的职工人数有: %d\n\n",c);getchar();}/***************************************************************************功能:导出函数***************************************************************************/ void save(){int k;FILE *fp;p=emp;if((fp=fopen("emp_list","wb"))==NULL){printf(" Create file error!\n");return;}for(k=0;k<N;k++,p++){if(fwrite(p,sizeof(struct employee),1,fp)!=1){printf(" file save error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}/***********************************************************************功能:导入函数***********************************************************************/ void load(){int l;FILE *fp;p=emp;if((fp=fopen("emp_list","rb"))==NULL){printf(" Create file error!\n");exit(0);}for(l=0;l<N;l++,p++){if(fread(p,sizeof(struct employee),1,fp)!=1){printf(" file read error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}下面是实验结果(注:素材和资料部分来自网络,供参考。

c语言职工工资管理系统代码

c语言职工工资管理系统代码

C语言职工工资管理系统代码1. 项目简介本项目是一个用C语言编写的职工工资管理系统。

该系统旨在帮助企业或组织更好地管理职工的工资信息,包括薪资计算、数据存储和查询等功能。

通过该系统,可以提高工资管理的效率和准确性,减少人力资源部门的负担。

2. 功能需求本系统需要实现以下功能:•添加新员工:输入员工姓名、基本工资、津贴等信息,并生成唯一的员工ID。

•删除员工:根据员工ID删除指定员工信息。

•修改员工信息:根据员工ID修改指定员工的基本信息。

•计算薪资:根据员工ID计算指定员工的实际薪资,并将结果保存到数据库中。

•查询薪资:根据员工ID查询指定员工的薪资信息。

3. 数据结构设计为了存储职工的基本信息和薪资数据,我们可以使用以下数据结构:3.1 员工结构体定义struct Employee {int id; // 员工IDchar name[50]; // 员工姓名float basicSalary; // 基本工资float allowance; // 津贴float actualSalary; // 实际薪资};3.2 员工数组定义struct Employee employees[100]; // 最多存储100个员工的信息int employeeCount = 0; // 当前员工数量4. 系统实现4.1 添加新员工void addEmployee() {struct Employee employee;printf("请输入员工姓名:");scanf("%s", );printf("请输入基本工资:");scanf("%f", &employee.basicSalary);printf("请输入津贴:");scanf("%f", &employee.allowance);employee.id = employeeCount + 1;employee.actualSalary = employee.basicSalary + employee.allowance;employees[employeeCount] = employee;employeeCount++;printf("添加成功!员工ID为:%d\n", employee.id);}4.2 删除员工void deleteEmployee() {int id;printf("请输入要删除的员工ID:");scanf("%d", &id);int index = findEmployeeIndex(id);if (index == -1) {printf("未找到对应的员工信息。

C工资管理系统源代码

C工资管理系统源代码

#include <>#include <>#include <>#include <>#include <>#define TITLE "\n 月份工号姓名应发工资各种折扣实发工资\n"#define DATA " %2d %4ld %-10s % % %\n",p1->month,p1->num,p1->nam e,p1->should_pay,p1->rebate,p1->actual_paytypedef struct pay{long num;short month;char name[20];float gw,jn,zw,zl,jt,yj;float should_pay;float fz,gj,sd,others;float rebate;float actual_pay;struct pay *next;}PAY;FILE *fp;PAY *p1=NULL,*p2=NULL,*head=NULL; void menu();PAY *input();void output();void save(PAY *head);PAY *open();PAY *insert();void search();PAY *del();PAY *revise();/*主程序模块*/void main(void){short sel;do{menu();scanf("%d",&sel);switch(sel){case 1:head=input(); 建工资档案\n");printf("\t\t\t\t2.新增工资信息\n");printf("\t\t\t\t3.修改工资信息\n");printf("\t\t\t\t4.删除工资信息\n");printf("\t\t\t\t5.查找工资信息\n");printf("\t\t\t\t6.分类信息列表\n");printf("\t\t\t\t7.保存信息\n");printf("\t\t\t\t0.退出\n");printf("\n\n\n\n\n\n\n\n");}/*输入模块*/PAY *input(){short n=1;p1=(PAY*)malloc(sizeof(PAY));if(p1==NULL){printf("内存不足,无法创建链表!");getch();}printf("\n请输入第%d位职工的信息(以工号为0结束):\n",n);printf(" 工号:");scanf("%d",&p1->num);if(p1->num==0){printf("按任意键返回!");getch();free(p1);return 0;}getchar();printf(" 姓名:");gets(p1->name);printf(" 工资月份:");scanf("%d",&p1->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);p1->should_pay=p1->gw+p1->jn+p1->zw+p1->zl+p1->jt+p1->yj;p1->rebate=p1->fz+p1->gj+p1->sd+p1->others;p1->actual_pay=p1->should_pay-p1->rebate;while(p1!=NULL){if(n==1)head=p1;elsep2->next=p1;n++;p2=p1;p1=(PAY*)malloc(sizeof(PAY));if(p1==NULL){printf("内存不足,无法创建链表!");getch();}printf("请输入第%d位职工的信息(以工号为0结束):\n",n); printf(" 工号:");scanf("%d",&p1->num);getchar();if(p1->num==0){p1=NULL;break;}printf(" 姓名:");gets(p1->name);printf(" 工资月份:");scanf("%d",&p1->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);p1->should_pay=p1->gw+p1->jn+p1->zw+p1->zl+p1->jt+p1->yj;p1->rebate=p1->fz+p1->gj+p1->sd+p1->others;p1->actual_pay=p1->should_pay-p1->rebate;}p2->next=NULL;部清单\n");printf("\t\t2.按月输出\n");printf("\t\t3.按工资段输出\n");printf("\t\t0.返回\n");scanf("%d",&sel);}while(sel!=1&&sel!=2&&sel!=3&&sel!=0);head=open();if(head==NULL)return;elseswitch(sel){case 1:printf("\n\t\t\t ******全部清单******\n"); printf(TITLE);p1=head;do{printf(DATA);p1=p1->next;}while(p1!=NULL);break;case 2:flag=0;printf("输入要查的月份:");scanf("%d",&month);printf("\n\t\t\t******第%d月工资清单******\n",month); printf(TITLE);p1=head;do{if(p1->month==month){printf(DATA);p1=p1->next;flag=1;}elsep1=p1->next;}while(p1!=NULL);if(flag==0)printf("没有该月清单\n");break;case 3:flag=0;printf("输入最低工资:");scanf("%f",&min);printf("输入最高工资:");scanf("%f",&max);printf("\n\t\t ******%到%工资的名单******\n",min,max); printf(TITLE);p1=head;do{if(p1->actual_pay>min&&p1->actual_pay<max){printf(DATA);p1=p1->next;flag=1;}elsep1=p1->next;}while(p1!=NULL);if(flag==0)printf("没有该工资段的职工\n");break;case 0:break;}}while(sel!=0);}/*保存文件*/void save(PAY *head){short write;fp=fopen("","w");if(fp==NULL){printf("创建文件失败!");getch();return;}p1=p2=head;while(p1!=NULL){write=fwrite(p1,sizeof(PAY),1,fp); if(!write){printf("无法写入文件!");getch();return;}p1=p1->next;}fclose(fp);printf("成功存盘!");getch();}/*打开文件*/PAY *open(){short n=1,read;fp=fopen("","r");if(fp==NULL){printf("无法打开档案文件!");getch();return NULL;}if((p1=p2=(PAY*)malloc(sizeof(PAY)))==NULL) {printf("内存不足!");getch();return NULL;}read=fread(p1,sizeof(PAY),1,fp);if(!read){printf("文件读取出错!1");getch();return NULL;}if(p1->next==NULL)head=p1;else{do{if(n==1)head=p1;elsep2->next=p1;n++;p2=p1;if((p1=(PAY*)malloc(sizeof(PAY)))==NULL){printf("内存不足!");getch();return NULL;}read=fread(p1,sizeof(PAY),1,fp); if(!read){printf("文件读取出错!2");getch();return NULL;}}while(p1->next!=NULL);p2->next=p1;}return head;fclose(fp);}/*插入模块*/PAY *insert(){PAY *p3=NULL;char sel;head=open();if(head==NULL)return NULL;elsedo{printf("请输入要插入的职工信息:\n");p3=(PAY*)malloc(sizeof(PAY));if(p3==NULL){printf("内存不足,无法创建链表!");getch();}printf(" 工号:");scanf("%d",&p3->num);getchar();printf(" 姓名:");gets(p3->name);printf(" 工资月份:");scanf("%d",&p3->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p3->gw,&p3->jn,&p3->zw,&p3->zl,&p3->jt,&p3->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p3->fz,&p3->gj,&p3->sd,&p3->others);p3->should_pay=p3->gw+p3->jn+p3->zw+p3->zl+p3->jt+p3->yj;p3->rebate=p3->fz+p3->gj+p3->sd+p3->others;p3->actual_pay=p3->should_pay-p3->rebate;p1=head;while(p1!=NULL){p2=p1;p1=p1->next;}p2->next=p3;p3->next=NULL;printf("成功插入,是否继续?是(Y)否(N)\n");sel=getch();}while(sel=='Y'||sel=='y');printf("\n任意键返回,并存盘……\n");getch();return head;}/*查找模块*/void search(){short sel;long num;char name[20],choose;head=open();if(head==NULL)return;elsedo{do{printf("\n选择查找方式:\n"); printf("\t\t1.按工号查找\n"); printf("\t\t2.按姓名查找\n"); scanf("%d",&sel);getchar();}while(sel!=1&&sel!=2);switch(sel){case 1:printf("输入要查的工号:");scanf("%ld",&num);break;case 2:printf("输入要查的姓名:");gets(name);break;}p1=head;while((p1->next!=NULL)&&(p1->num!=num)&&(strcmp(p1->name,name)!=0)) 工号删除\n");printf("\t\t2.按姓名删除\n");scanf("%d",&sel);getchar();}while(sel!=1&&sel!=2);switch(sel){case 1:printf("输入要删除的工号:");scanf("%ld",&num);break;case 2:printf("输入要删除的姓名:");gets(name);break;}p1=head;if((p1->num==num)||strcmp(p1->name,name)==0){head=p1->next;printf("删除信息成功!");}else{while((p1->next!=NULL)&&(p1->num!=num)&&(strcmp(p1->name,name)!=0)) {p2=p1;p1=p1->next;}if((p1->num==num)||strcmp(p1->name,name)==0){p2->next=p1->next;free(p1);printf("\n删除信息成功!\n");}elseprintf("\n没有该信息!\n");}printf("是否继续?是(Y)否(N)\n"); choose=getch();}while(choose=='Y'||choose=='y');printf("任意键返回,并存盘……");getch();return head;}/*修改模块*/PAY *revise(){short sel;long num;char name[20],choose;head=open();if(head==NULL)return NULL;elsedo{do{printf("\n查找要修改的对象:\n"); printf("\t\t1.按工号查找\n");printf("\t\t2.按姓名查找\n");scanf("%d",&sel);getchar();}while(sel!=1&&sel!=2);switch(sel){case 1:printf("输入要查的工号:");scanf("%ld",&num);break;case 2:printf("输入要查的姓名:");gets(name);break;}p1=head;while((p1->next!=NULL)&&(p1->num!=num)&&(strcmp(p1->name,name)!=0)) //用成p1!=NULL有问题?p1=p1->next;if((p1->num==num)||strcmp(p1->name,name)==0){printf("您要修改的原始信息如下:\n");printf(TITLE);printf(DATA);printf("\n将上述信息改为如下信息:\n");printf(" 工号:");scanf("%d",&p1->num);getchar();printf(" 姓名:");gets(p1->name);printf(" 工资月份:");scanf("%d",&p1->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);p1->should_pay=p1->gw+p1->jn+p1->zw+p1->zl+p1->jt+p1->yj;p1->rebate=p1->fz+p1->gj+p1->sd+p1->others;p1->actual_pay=p1->should_pay-p1->rebate;}elseprintf("你要修改的信息不存在!\n");printf("是否继续?是(Y)否(N)\n");choose=getch();}while(choose=='Y'||choose=='y');printf("任意键返回,并存盘……");getch();return head;}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

职工工资纳税管理信息系统 c 项目源代码功能强大#include<iostream>#include<fstream>#include<string>#include<iomanip>#include"conio.h"using namespace std;void login();void zhuye(string user);string username="";void insert();void update();void del();void select();void cont();void add();bool contain(char* ch,fstream &file); bool contain2(char* ch,fstream &file);float getam2(float bm,int am); char* getfname(fstream &file,char* ch);long getl(fstream &file); long getl2(fstream &file); long getl3(char *c,fstream &file); long l1,l2;int error=0;int i2=0;int i3=0;fstream iofile;fstream iofile2;//职工工资信息class worker{public:worker();worker(int a){}char* getno(){return no;}char* getname(){return name;}float getbm(){return bmoney;}float getam(){return amoney;}void setbm(float fl){bmoney=fl;} void setdel(bool bb){b=bb;}void setmmoney(float fl){mmoney=fl;} void setamoney(float fl){amoney=fl;} bool b;int title;private:char no[5];char name[7];float bmoney;float amoney;float mmoney;};worker::worker(){b=true;int x=0;title=1;cout<<"请输入第"<<i2+1<<"个"<<"职工号:";cin>>no;do{if(x!=0){system("cls");cout<<"工资低于底薪1600,请重新输入工资:"<<endl; }cout<<"请输入第"<<i2+1<<"个"<<"职工工资额:"; cin>>bmoney;x++;}while(bmoney<1600);mmoney=bmoney-1600; //应纳税所得额amoney=getam2(mmoney,bmoney); //税后所得工资strcpy(name,getfname(iofile2,no));//cout<<name<<"-----"; }//职工个人信息class worker2{public:worker2();worker2(int a){}char* getn();char* getname();private:char name[7];char no[5];};worker2::worker2() {cout<<"请输入第"<<i3+1<<"个"<<"职工号:";//职工号不能重复~~还要有权限fflush(stdin);cin>>no;cout<<"请输入第"<<i3+1<<"个"<<"职工姓名:";fflush(stdin);cin>>name;}char* worker2::getn(){return no;}char* worker2::getname(){return name;}//主函数int main(){login();return 0;}//登陆函数void login(){system("cls");char before;int abcd;string user;char pa[20];cout<<"请输入用户名:"; cin>>user;cout<<"请输入密码:"; for(int j=0;j<10;j++) {before=getch();if(before==13){pa[j]='\0';break;}if(before==8){before=getchar();}else{pa[j]=before;cout<<'*';}}if(strcmp(pa,"123")==0||strcmp(pa,"456")==0){zhuye(user);}else{do{error++;if(error==3){cout<<endl;cout<<"密码错误3次,系统自动退出,请稍后重新登录~"; for(abcd=1;abcd<=100000000;abcd++){}exit(1);}cout<<"密码错误~请重新输入";for(abcd=1;abcd<=100000000;abcd++){}login();}while(error<3);}}//登陆成功,进入主页void zhuye(string user) {while(true){system("cls");iofile.open("work.txt",ios::in|ios::out);iofile2.open("workinfo.txt",ios::in|ios::out); if(!iofile||!iofile2){cout<<"cuole";}username=user;cout<<"当前用户: "<<username<<endl;cout<<endl;cout<<" 1.职工工资信息录入"<<endl;cout<<" 2.职工工资信息修改"<<endl;cout<<" 3.职工工资信息删除"<<endl;cout<<" 4.查询纳税金额"<<endl; cout<<" 5.添加职工"<<endl; cout<<" 6.退出"<<endl;cout<<endl;char x;cout<<"请选择你要执行的功能:"; cin>>x;switch(x){case '1':insert();break;case '2':update();break;case '3':del();break;case '4':select();break;case '5':add();break;case '6':exit(1);break;default:cout<<"请输入1——6的数字~";for(int i=0;i<100000000;i++){}iofile.close();iofile2.close();break;}}}//添加职工工资信息void insert(){int size=0;i2=0;char e,e2,n,f;system("cls");iofile<<left;cout<<"请输入你要添加职工信息的数目:"; cin>>size;// while(i2<size)// {do{l1=getl(iofile);l2=getl2(iofile2);//有contain,worker的地方都要用worker work;if(contain(work.getno(),iofile2)){if(contain2(work.getno(),iofile)){cout<<"此前已有"<<work.getname()<<"的工资信息!"<<endl;cout<<"覆盖原来信息输'f',添加输't',退出输'n',其他任意键回主页:"; cin>>f;if(f=='t'){iofile.seekp(0,ios::end);iofile.write((char*)&work,sizeof(work));i2++;if(i2==size)break;}else if(f=='n'){exit(1);}else if(f=='f'){long l=getl3(work.getno(),iofile);cout<<l/sizeof(work);iofile.seekg(l);iofile.write((char*)&work,sizeof(work)); i2++;if(i2==size)break;}else{iofile.close();iofile2.close();return;}}else{iofile.seekp(0,ios::end);iofile.write((char*)&work,sizeof(work)); i2++;if(i2==size)break;}}else{cout<<"没有此号,请确认输入无误~继续输入输'y'"<<endl<<"添加用户输入't',退出输'n',其他任意键回主页:";cin>>n;if(n=='n'){exit(1);}else if(n=='t'){add();return;}else if(n=='y'){system("cls");cout<<"请继续输入:"<<endl;// i2++;}else{iofile.close();iofile2.close();return;}}}while(n=='y'||i2<size); // }cout<<"是否还要添加职工工资信息,"<<endl;cout<<" 若要继续请输'Y',退出输'N',回主页输其他任意键:"<<endl; cin>>e;if(e=='y'||e=='Y'){cout<<"请继续添加职工工资信息"<<endl;do{worker work2;if(contain(work2.getno(),iofile2)){cout<<"有";iofile.write((char*)&work2,sizeof(work2));cout<<"继续添加输'y',推出输'N',回主页输其他任意键:"<<endl; cin>>e2;}else{cout<<"没有";}}while(e2=='y'||e2=='Y'); if(e2=='n'||e2=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}else if(e=='n'||e=='N') {iofile.close();iofile2.close();exit(1);}else{iofile.close();iofile2.close();return;}}void update(){system("cls");// int length=getl(iofile);char c[5],e,e2;float fl;int byte=0;worker work(1);cout<<"请输入您要修改的号码:";cin>>c;iofile.seekg(0);iofile.read((char *)&work,sizeof(work)); while(!iofile.eof()){if(strcmp(c,work.getno())==0){break;}iofile.read((char *)&work,sizeof(work)); byte++;}cout<<"请输入要修改的工资:";cin>>fl;work.setbm(fl);work.setmmoney(fl-1600);work.setamoney(getam2(fl-1600,fl));iofile.seekp(byte*sizeof(work));iofile.write((char *)&work,sizeof(work));cout<<"是否还要修改职工工资信息,"<<endl;cout<<" 若要继续请输'Y',退出输'N',回主页输其他任意键:"<<endl; cin>>e;if(e=='y'||e=='Y'){cout<<"请继续输入您要修改的号码:";cin>>c;iofile.seekg(0);while(!iofile.eof()){iofile.read((char *)&work,sizeof(work));if(strcmp(c,work.getno())==0){break;}byte++;}cout<<"请输入要修改的工资:";cin>>fl;work.setbm(fl);work.setmmoney(fl-1600);work.setamoney(getam2(fl-1600,fl));iofile.seekp(byte*sizeof(work));iofile.write((char *)&work,sizeof(work));cout<<"继续修改输'y',退出输'N',回主页输其他任意键:"<<endl; cin>>e2;while(e2=='y'||e2=='Y');if(e2=='n'||e2=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}else if(e=='n'||e=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}void del(){system("cls");int length=getl(iofile);char c[5],e,e2;int byte=0;worker work(1);cout<<"请输入您要删除的号码:";cin>>c;iofile.seekg(0);while(!iofile.eof()){iofile.read((char *)&work,sizeof(work)); if(strcmp(c,work.getno())==0){break;}}byte=iofile.tellg()/sizeof(work)-1;/* work.setdel(false);iofile.seekp(byte*sizeof(work));iofile.write((char *)&work,sizeof(work));*/while(!iofile.eof()){iofile.seekg((byte+1)*sizeof(work));iofile.read((char *)&work,sizeof(work));iofile.seekp(byte*sizeof(work));iofile.write((char *)&work,sizeof(work));byte++;if(byte+1==length)break;}iofile.seekp(-sizeof(work),ios::end);for(int l=0;l<sizeof(work);l++){iofile.put(NULL);}cout<<"删除成功~"<<endl;cout<<"是否还要删除职工工资信息,"<<endl;cout<<" 若要继续请输'Y',退出输'N',回主页输其他任意键:"<<endl; cin>>e;if(e=='y'||e=='Y'){cout<<"请继续删除职工工资信息"<<endl;do{cout<<"请输入您要删除的号码:";cin>>c;iofile.seekg(0);while(!iofile.eof()){iofile.read((char *)&work,sizeof(work)); if(strcmp(c,work.getno())==0){break;}}byte=iofile.tellg()/sizeof(work)-1;while(!iofile.eof()){iofile.seekg((byte+1)*sizeof(work)); iofile.read((char *)&work,sizeof(work)); iofile.seekp(byte*sizeof(work));iofile.write((char *)&work,sizeof(work)); byte++;if(byte+1==length)break;}iofile.seekp(-sizeof(work),ios::end);for(int l=0;l<sizeof(work);l++){iofile.put(NULL);}cout<<"删除成功"<<endl;cout<<"继续删除输'y',退出输'N',回主页输其他任意键:"<<endl; cin>>e2;}while(e2=='y'||e2=='Y');if(e2=='n'||e2=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}else if(e=='n'||e=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}void select(){char c,type;do{system("cls");char n[5];char name[7];cout<<left;long l=getl(iofile);worker work(1);cout<<" 欢迎进入信息查询"<<endl; cout<<" 1.查询所有"<<endl;cout<<" 2.按号码查询"<<endl; cout<<" 3.按姓名查询"<<endl; cout<<endl<<"请选择查询方式:";cin>>type;if(type=='1'){system("cls");cout<<setw(7)<<"号码"<<setw(9)<<"姓名"<<setw(16)<<"税前工资"<<setw(16)<<"税后工资"<<endl;iofile.seekg(0,ios::beg);/*iofile.read((char*)&work,sizeof(work));while(!iofile.eof())//此处需读一遍才会退出循环{if(work.b==true){cout<<!iofile<<setw(7)<<work.getno()<<setw(9)<<work.getname()<<setw( 16)<<work.getbm()<<setw(16)<<work.getam()<<endl;}iofile.read((char*)&work,sizeof(work));}*//* while(iofile.read((char*)&work,sizeof(work))){cout<<!iofile<<setw(7)<<work.getno()<<setw(9)<<work.getname()<<setw( 16)<<work.getbm()<<setw(16)<<work.getam()<<endl;}*/for(int i=0;i<l;i++){iofile.read((char*)&work,sizeof(work));if(work.getbm()!=0)cout<<setw(7)<<work.getno()<<setw(9)<<work.getname()<<setw(16) <<work.getbm()<<setw(16)<<work.getam()<<endl;}cout<<"退出输'n',回主页输其他任意键:";cin>>c;if(c=='n'||c=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}else if(type=='2'){system("cls");cout<<"请输入要查询的学号:";cin>>n;long tl=getl3(n,iofile);iofile.seekg(tl);iofile.read((char*)&work,sizeof(work));cout<<setw(7)<<"号码"<<setw(9)<<"姓名"<<setw(16)<<"税前工资"<<setw(16)<<"税后工资"<<endl;iofile.seekg(0,ios::beg);cout<<setw(7)<<work.getno()<<setw(9)<<work.getname()<<setw(16) <<work.getbm()<<setw(16)<<work.getam()<<endl;cout<<"退出输'n',回主页输其他任意键:";cin>>c;if(c=='n'||c=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}else if(type=='3'){system("cls");cout<<"请输入要查询的姓名:";cin>>name;long tl=getl3(name,iofile);iofile.seekg(tl);iofile.read((char*)&work,sizeof(work));cout<<setw(7)<<"号码"<<setw(9)<<"姓名"<<setw(16)<<"税前工资"<<setw(16)<<"税后工资"<<endl;iofile.seekg(0,ios::beg);cout<<setw(7)<<work.getno()<<setw(9)<<work.getname()<<setw(16) <<work.getbm()<<setw(16)<<work.getam()<<endl;cout<<"退出输'n',回主页输其他任意键:";cin>>c;if(c=='n'||c=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}else{cout<<"请输入1——3的数字~";for(int i=0;i<100000000;i++){}}}while(type!='1'&&type!='2'&&type!='3');}//添加职工基本信息void add(){int size=0;i3=0;char e,e2;system("cls");iofile2.seekp(0,ios::end);iofile<<left;cout<<" 欢迎进入添加职工成员~"<<endl;cout<<"请输入你要添加职工信息的数目:"; cin>>size;while(i3<size){worker2 work2;iofile2.write((char*)&work2,sizeof(work2));i3++;}cout<<"是否还要添加职工信息,"<<endl;cout<<" 若要继续请输'Y',退出输'N',回主页输其他任意键:"<<endl; cin>>e;if(e=='y'||e=='Y'){cout<<"请继续添加职工信息"<<endl;do{worker2 work2;iofile2.write((char*)&work2,sizeof(work2));cout<<"继续添加输'y',推出输'N',回主页输其他任意键:"<<endl; cin>>e2;}while(e2=='y'||e2=='Y');if(e2=='n'||e2=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}else if(e=='n'||e=='N'){exit(1);}else{iofile.close();iofile2.close();return;}}//判断用户有无bool contain(char* ch,fstream &file) {worker2 work(1);file.seekg(0);int flag=0;for(int i=0;i<l2;i++){file.read((char*)&work,sizeof(work)); if(strcmp(ch,work.getn())==0){flag=1;break;}}if(flag==1){return true;}else{return false;}}//获取用户名char* getfname(fstream &file,char* ch) {worker2 work3(1);file.seekg(0);for(int i=0;i<l2;i++){file.read((char*)&work3,sizeof(work3)); if(strcmp(ch,work3.getn())==0){break;}}return work3.getname();}//获取数目long getl(fstream &file){file.seekg(0,ios::end);worker work(1);return (file.tellg())/sizeof(work); } long getl2(fstream &file){file.seekg(0,ios::end);worker2 work(1);return (file.tellg())/sizeof(work); } //获取位置long getl3(char *c,fstream &file) { worker work(1);file.seekg(0);for(int i=0;i<l1;i++){file.read((char *)&work,sizeof(work)); if(strcmp(c,work.getno())==0)break;}return file.tellg()-(long)sizeof(work); }//判断是否已有工资信息bool contain2(char* ch,fstream &file) { worker work(1);file.seekg(0);int flag=0;for(int i=0;i<l1;i++){file.read((char*)&work,sizeof(work)); if(strcmp(ch,work.getno())==0){flag=1;break;}}if(flag==1){return true;}else{return false;}}//获取职工税后工资float getam2(float bm,int am){if(bm<=500){return am-bm*5/100;}else if(bm<=2000){return am-500*5/100-(bm-500)*10/100;}else if(bm<=5000){return am-500*5/100-1500*10/100-(bm-2000)*15/100;}else if(bm<=20000){return am-500*5/100-1500*10/100-3000*20/100-(bm-5000)*20/100;}else if(bm<=40000){returnam-500*5/100-1500*10/100-3000*20/100-20000*20/100-(bm-20000)*25/100;}else if(bm<=60000){returnam-500*5/100-1500*10/100-3000*20/100-20000*20/100-20000*25/100-(bm-40000)*30/100;}else if(bm<=80000){returnam-500*5/100-1500*10/100-3000*20/100-20000*20/100-20000*25/100-20000*30/100-(bm-60000)*35/100;}else if(bm<=100000){returnam-500*5/100-1500*10/100-3000*20/100-20000*20/100-20000*25/100-20000*30/100-20000*35/100-(bm-80000)*40/100;}else{returnam-500*5/100-1500*10/100-3000*20/100-20000*20/100-20000*25/100-20000*30/100-20000*35/100-20000*40/100-(bm-100000)*45/100;}}。

相关文档
最新文档