c语言课程设计 职工信息管理系统



《c语言课程设计 职工信息管理系统》由会员分享,可在线阅读,更多相关《c语言课程设计 职工信息管理系统(8页珍藏版)》请在装配图网上搜索。
1、C语言课程设计
1. 设计题目:职工信息管理系统
2. 系统功能简介:
系统以菜单方式工作
1) 职工信息录入(文件保存职工信息)
2) 输出职工信息、浏览职工信息
3) 查询职工信息
4) 根据员工号查找职工信息
5) 根据工资、年龄、性别对职工信息进行排序
6) 删除职工信息
3. 设计实施:
#include
2、name*/ int Sex; /*sex 1- woman 2- man*/ int Old; /* old*/ int Cult; /*education background 1-specilist 2-doctor 3-others*/ int Salary; /*salary*/ char Address[12]; /* address*/ int Tell; /*telephone number*/ }Emp; Emp emp[100]; void open() { int i; FILE *fp; if((fp=fopen(〃wyl〃,〃
3、rb+〃))==NULL) {printf("can not do it! Because of no file of information、/); exit(0);} for(i=0;i<100;i++) {if(fread(&emp[i],sizeof(Emp),1,fp)==0) {printf("Fail to output\n〃); exit(0);} } fclose(fp); } void close() /* 跳出 */ { int i; FILE *fp; if((fp=fopen(〃wyl〃,〃wr+〃))==NULL) {printf("c
4、an not do it!\n〃); exit(0);} for(i=0;i<100;i++) fwrite(&emp[i],sizeof(Emp),1,fp); fclose(fp); } void inputEmpInfo() /*输入信息 */ { int i,k; for(i=0;i<100;i++) { printf("Please enter the staff's :\nnumber:〃); scanf(〃%d〃,&emp[i].EmpNum); printf(〃\nname:〃); scanf(〃%s〃,emp[i].EmpName); print
5、f("\nsex : 1- woman 2- man:"); scanf(〃%d〃,&emp[i].Sex); printf("\nold:"); scanf(〃%d〃,&emp[i].Old); printf("\nEducation background:1-specialist 2-doctor 3-others"); scanf(〃%d〃,&emp[i].Cult); printf("\nsalary:"); scanf(〃%d〃,&emp[i].Salary); printf("\naddress:"); scanf("%s",emp[i].Address); p
6、rintf(〃\ntellphone:〃); scanf(〃%d〃,&emp[i].Tell); printf("continue?(1.yes 2.no)〃); scanf(〃%d〃,&k); if(k==2) break; } close(); } void reorder() /* 修改 */ { int i,s,j,k,l; Emp temp; open(); printf("\nChoose which category would you want to use\n1 sex \n2 salary(from maximum to minimum) \n3—ol
7、d (from maximum to minimum) \n ( enter the corresponding nember) \n)〃); scanf(〃%d〃,&i); switch(i) { case 1: printf("\nchoose which sex do you want to inquire? 1—woman 2 —man "); scanf(〃%d〃,&s); for(j=0;emp[j].EmpNum!=0;j++) { if(emp[j].Sex==s) { printf(" number:%d\n〃,emp[j].EmpNum); print
8、f(〃name:%s〃, emp[j].EmpName); printf("\nsex 1- woman 2- man:%d", emp[j].Sex); printf(〃\nold:%d〃, emp[j].Old); printf("\neducation background:%d\t\t\t 1-specialist 2-doctor 3-others 〃,emp[j].Cult); printf(〃\nsalary:%d〃, emp[j].Salary); printf(〃\naddress:%s〃, emp[j].Address); printf("\ntelephone
9、 nember :%d", emp[j].Tell);
}
}
break;
case 2:
for(k=0;emp[k].EmpNum!=0;j++ )
{
for(l=k;emp[l].EmpNum!=0;l++)
if(emp[l].Salary 10、- man:%d〃,emp[k].Sex);
printf(〃\nold:%d〃,emp[k].Old);
printf("\neducation background:%d\t\t\t 1-specialist 2-doctor 〃,emp[k].Cult);
printf(〃\nsalary:%d〃,emp[k].Salary);
printf(〃\nadress:%s〃,emp[k].Address);
printf("\ntelephone nember :%d〃,emp[k].Tell);
}
break;
case 3:
for(k=0;emp[k].EmpNum 11、!=0;j++ )
{
for(l=k;emp[l].EmpNum!=0;l++)
{
if(emp[l].Old 12、background:%d\t\t\t 1-specialist
3-others〃,emp[k].Cult);
printf(〃\nsalary:%d〃,emp[k].Salary);
printf(〃\naddress:%s〃,emp[k].Address);
printf("\ntelephone nember :%d",emp[k].Tell);
}
break;
}
}
void show()
{
int j;
open();
printf("\n informations
3-others
2-doctor
of
sraffs \n〃);
for 13、(j=0;emp[j].EmpNum!=0;j++)
{
printf(〃number:%d\n〃,emp[j].EmpNum);
printf(〃name:%s〃,emp[j].EmpName);
printf("\nsex 1- woman 2- man:%d〃,emp[j].Sex);
printf(〃\nold:%d〃,emp[j].Old);
printf("\neducation background:%d 1-specialist 2-doctor 3-others
〃,emp[j].Cult);
printf(〃\nsalary:%d〃,emp[j].Salar 14、y);
printf(〃\nadress:%s〃,emp[j].Address);
printf("\ntelephone nember :%d",emp[j].Tell);
}
}
void deleteEmp()
{
int j,k,m=1,d,i=0;
open();
printf("Enter the number whose date you want to delete:\n〃);
scanf(〃%d〃,&d);
for(j=0;emp[j].EmpNum!=0;j++)
{
if(emp[j].EmpNum==d)
{
for(k=j;emp[j]. 15、EmpNum!=0;k++)
emp[k]=emp[k+1];
i++;
}
}
if(i==0)
printf("The staffs informations manage systerm has no date of the number your entered!!!\n〃);
close();
printf("succeeed to delete\n〃);
}
void findByEmpName() /* 查询 */ { int j,i,k=0;
open();
printf("Please enter the number :\n〃); scanf(〃%d 16、〃,&i);
for(j=0;emp[j].EmpNum!=0;j++)
{if(emp[j].EmpNum==i)
{
printf("\n information of your want
\n〃);
printf(〃number:%d\n〃,emp[j].EmpNum);
printf(〃name:%s〃,emp[j].EmpName);
printf("\nsex 1- woman 2- man:%d〃,emp[j].Sex);
printf(〃\nold:%d〃,emp[j].Old);
printf("\neducation background:%d\t\t 17、\t\t 1-specialist 2-doctor 3-others 〃,emp[j].Cult);
printf(〃\nsalary:%d〃,emp[j].Salary);
printf(〃\nadress:%s〃,emp[j].Address);
printf("\ntelephone number:%d〃,emp[j].Tell);
k++;
}
}
if(k==0)
printf("\nHave no date of the number!!!\n〃);
}
void menu()
{
printf("\n
\n〃);
printf("\n Wellc 18、ome to the staff manage styterm
\n〃);
printf("\n
\n〃);
printf("Please choose number for what are you want to do:\n\n〃);
printf("\n 1 input: Complete inputing workers' information.");
printf("\n 2 reorder: Make the new order of the information.");
printf("\n 3 delete: Delete the inform 19、ation of the staff.");
printf("\n 4 output: Display all worker of information.");
printf("\n 5 inquire.");
printf("\n 0 exit\n");
}
void main()
{
int op,choice=1;
while(choice==1)
{
menu();
printf("\nPlease enter your order:\n");
scanf("%d",&op);
switch(op)
{case 1: inputEmpInfo();b 20、reak;
case 2: reorder();break;
case 3: deleteEmp();break;
case 4: show();break;
case 5: findByEmpName();break;
case 0: {printf("Welcome to use worker management system, goodbye!!!");
exit(0);}
getchar();}
printf("\n
\n");
printf("\nWhether continue? Yes-1 No—2\n");
scanf("%d”,choice);
}
}
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。