分享
 
 
 

员工管理系统(链表)

王朝other·作者佚名  2008-06-01
窄屏简体版  字體: |||超大  

#include <stdio.h>

#include <conio.h>

#include <process.h>

#define OUTPUT temp->num,temp->name,temp->gender,temp->age,temp->department,temp->telephone,temp->wage

#define FORMAT "%-10lu%-13s%-9c%-6u%-18s%-13lu%lu\n"

#define INFO "number\t name\t gender\tage department\ttelephone wage\n"

char ch;

unsigned int mn,fn,find;

unsigned long msum,fsum;

strUCt workers

{

char name[15],department[18],gender;

unsigned int age;

unsigned long telephone,wage,num;

struct workers *next;

};struct workers *head,*bottom,*temp,*p;

create()

{

int i;

head=NULL;

mn=fn=msum=fsum=0;

for (i=0;;i++)

{

printf("\n Information of worker NO.%d(Press '*' when input worker's name if finish)",i+1);

insert();

}

getch();

return main();

}

analysis()

{

clrscr();

printf("\n**********************************Wage report*********************************\n");

printf(INFO);

temp=head;

while(temp!=NULL)

{

printf(FORMAT,OUTPUT);

temp=temp->next;

}

if(head==NULL)

printf("\n\t\t\t\No worker in list,please entry first!");

showreport();

}

showreport()

{

FILE *report;

report=fopen("report.dat","w");

fprintf(report,"\n\n\tGender\t\t\tFemale\t\tMale\t\tTotal");

fprintf(report,"\n\tNumber\t\t\t%d\t\t%d\t\t%d",fn,mn,fn+mn);

fprintf(report,"\n\tTotal wage\t\t%lu\t\t%lu\t\t%lu",fsum,msum,fsum+msum);

if(mn==0&&fn==0)

fprintf(report,"\n\tAverage wage\t\t0.00\t\t0.00\t\t0.00");

else if(fn==0)

fprintf(report,"\n\tAverage wage\t\t0.00\t\t%.2f\t\t%.2f",(float)(msum/mn),(float)(msum/mn));

else if(mn==0)

fprintf(report,"\n\tAverage wage\t\t%.2f\t\t0.00\t\t%.2f",(float)(fsum/fn),(float)(fsum/fn));

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)));

ch=fgetc(report);

fclose(report);

report=fopen("report.dat","r");

while(feof(report)==0)

{

putchar(ch);

ch=fgetc(report);

}

fclose(report);

}

search()

{

unsigned long fnum;

find=0;

temp=head;

do

{

printf("\nWorker's number you want to find:");

fflush(stdin);

scanf("%lu",&fnum);

if(fnum<1fnum>100000000)

printf("\tWorker's number is required from 1 to 100000000!");

}while(fnum<1fnum>100000000);

while(temp->next!=NULL&&fnum!=temp->num)

{

p=temp;

temp=temp->next;

}

if(fnum==temp->num)

{

find=1;

printf("\n");

printf(INFO);

printf(FORMAT,OUTPUT);

}

else

{

find=0;

printf("\n\t\t\tNot found this worker!");

}

}

insert()

{

if(head==NULL)

{

bottom=temp=(struct workers *)malloc(sizeof(struct workers));

head=temp;

}

else

{

temp=(struct workers *)malloc(sizeof(struct workers));

bottom->next=temp;

}

do{

printf("\nWorker's name:");

fflush(stdin);

scanf("%s",temp->name);

if(strlen(temp->name)>15)

printf("\tThe length of worker's name must less than 15!");

}while(strlen(temp->name)>15);

if (temp->name[0]!='*')

{

add();

bottom->next=temp;

bottom=temp;

}

else

{

free(temp);

bottom->next=NULL;

if(fn+mn==0)

head=NULL;

printf("\n\t\t\t\Entry finish,press any key to return...");

getch();

return main();

}

bottom->next=NULL;

}

add()

{

do{

printf("Worker's number:");

fflush(stdin);

scanf("%lu",&temp->num);

if(temp->num<1temp->num>100000000)

printf("\tWorker's number is required from 1 to 100000000!\n");

}while(temp->num<1temp->num>100000000);

do

{

printf("Worker's gender('m','f','M'or'F'):");

fflush(stdin);

scanf("%c",&temp->gender);

if((temp->gender!='m')&&(temp->gender!='f')&&(temp->gender!='M')&&(temp->gender!='F'))

printf("\tPlease input as 'm','f','M'or'F'!\n");

}while((temp->gender!='m')&&(temp->gender!='f')&&(temp->gender!='M')&&(temp->gender!='F'));

do

{

printf("Worker's age:");

fflush(stdin);

scanf("%u",&temp->age);

if(temp->age<=18temp->age>=100)

printf("\tWorker's age must more than 18 and less than 100!\n");

}while(temp->age<=18temp->age>=100);

do{

printf("Worker's department:");

fflush(stdin);

scanf("%s",&temp->department);

if(strlen(temp->department)>18)

printf("\tThe length of worker's department must less than 18!\n");

}while(strlen(temp->department)>18);

do

{

printf("Worker's telephone(8 digit):");

fflush(stdin);

scanf("%lu",&temp->telephone);

if(temp->telephone>99999999temp->telephone<10000000)

printf("\tContact telephone is 8 digit!\n");

}while(temp->telephone>99999999temp->telephone<10000000);

do

{

printf("Worker's wage(more than 100):");

fflush(stdin);

scanf("%lu",&temp->wage);

if(temp->wage<100)

printf("\tThis worker's wage mustn't below 100!\n");

}while(temp->wage<100);

if((temp->gender=='m')(temp->gender=='M'))

{

msum+=temp->wage;

mn++;

}

else

{

fsum+=temp->wage;

fn++;

}

}

delete()

{

search();

if(find==1)

{

printf("\n Do you want to delete this worker?(Y/N)");

fflush(stdin);

ch=getchar();

if(ch=='y'ch=='Y')

{

if(temp==head)

head=temp->next;

else

p->next=temp->next;

if(temp->gender=='m'temp->gender=='M')

{

msum-=temp->wage;

mn--;

}

else if(temp->gender=='f'temp->gender=='F')

{

fsum-=temp->wage;

fn--;

}

free(temp);

analysis();

printf("\n\n\n\t\t\tDelete OK,press any key to return...");

getch();

return m

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有