1、void menu();void printf_face()/*显示数据结构项目函数*/ printf(num name sex age duty titile landscape quilification servicetime cometime categoryn); void printf_one(struct staff p)/*输出单个数据函数*/ %-4s%-7s%-6s%-3d%-11s%-7s%-8s%-18s%-7d%-12s%-3sn,p.num,p.name,p.sex,p.age,p.duty,p.title,p.p_landscape,p.Qualification
2、s,p.Service_time,e_time,p.category);int load()/*加载函数*/ int i=0;FILE *fp;if(fp=fopen(text.txt,rb)=NULL) return 0; exit(0);for(i=0;!feof(fp);i+) /*输出数据到结构体*/ fscanf(fp,%s %s %s %d %s %s %s %s %d %s %sn,staffi.num,staffi.name,staffi.sex,&staffi.age,staffi.duty,staffi.title,staffi.p_landscape,staffi.Qua
3、lifications,&staffi.Service_time,e_time,staffi.category);fclose(fp);return i;int search_data()/*查找单个数据函数*/ int i,flag;char s30,w0;system(cls/*清屏*/ n=load();do fflush(stdin); /*清除缓冲区输入*/ By1)Number 2)Name bbw0=getchar(); while(w02if(w0=)/*按编号查找*/ flag=0;puts(Enter staffs number:scanf(%s,s);in;i+) if(
4、strcmp(s,staffi.num)=0) printf_face();printf_one(staffi);flag=1;break;else continue;if(flag=0)puts(The staffs name dosenot exsist !else /*按姓名查找*/ Enter staff name:if(strcmp(s,staffi.name)=0) if(flag=0) puts(s message dosenot exsist !void save_all()/*保存所有数据函数*/ int i;wbCannotopen file!exit(0);if(staf
5、fi.age!=0) fprintf(fp,staffi.num,staffi.name,staffi.sex,staffi.age,staffi.duty,staffi.title,staffi.p_landscape,staffi.Qualifications,staffi.Service_time,e_time,staffi.category);int test(char h10)/*检查编号是否重复*/ i+) if(strcmp(h,staffi.num)=0) The number has exsist!please nter again!pausereturn 1;void sa
6、ve(struct staff p)/*保存单个数据函数*/ ab+Cannot open file!Succeseful to save message!n/*修改模块*/ void modify() int k=0,w0,g;char h30,w1,w2;loop: g=search_data();if(gn) tttModify: 1)Numderttt 2)Namettt 3)Sexttt 4)Agettt 5)Dutyttt 6)Titlettt 7)Landscapettt 8)Qualificationsttt 9)Service timettt 10)Come timettt
7、11)Category Please choice : bb%d,&w0);while(w011);switch(w0) case 1:Enter New Number:,h);strcpy(staffg.num,h);case 2:Enter name:strcpy(staffg.name,h);case 3:Enter sex:strcpy(staffg.sex,h);case 4:Enter age:k);staffg.age=k;case 5:Enter duty:strcpy(staffg.duty,h);case 6:Enter titile:strcpy(staffg.title
8、,h);case 7:Enter landscape:strcpy(staffg.p_landscape,h);case 8:Enter qualiications:strcpy(staffg.Qualifications,h);case 9:Enter service time:staffg.Service_time=k;case 10:Enter come time:strcpy(e_time,h);case 11:Enter category:strcpy(staffg.category,h);Are you sure to save?1)Yes 2)No bbw1=getchar();
9、while(w1if(w1=)save_all(); puts(Succesefull to save!1)Continue to modify 2)Back to menu 3)Exist bbw2=getchar();while(w23if(w2=)goto loop;else if(w2=)menu();else exit(0);/*保存模块*/ void zhun()char w0;save_all();Have save all message!1) Back to menu 2) Exist bb/*查找模块*/ void search() int k;char w1; k=sea
10、rch_data();1)Back to menu 2)Exist 3)Continue to search bbelse if(w1=)exit(0);else goto loop;/*增加模块*/ void add() char w0,w1; system(munder(exmple 001):,s.num);if(test(s.num)goto loop;/*编号重复*/ name:,s.name);sex(male,female):,s.sex);age:s.age);duty(jiaochou fujiaochou jiangshi zhujiao xuesheng houjin):
11、,s.duty);title (NO low hight):,s.title);landscape( party not ):,s.p_landscape);hightest qualifications(xiaoxue zhuzhong gaozhong daxue shuoshi gengao):,s.Qualifications);serve time:s.Service_time);come time(example 20050101):,e_time);category(massenger teacher staff enteir linshigong):,s.category);S
12、ave or not?1)Yes 2)No bbswitch(w0-48) case 1:save(s);1)Coninnue to add 2)Back to menu 3)Exist bb/*删除模块*/ void delete_data() char w0,w1;if(kAre you sure to delete? 1)Yes 2)No bb) staffk.age=0;This staff massege has deleteed!1)Continue to delete 2)Back to menu 3)Exisi bb) goto loop;/*统计模块*/ void stast
13、ic() int i,count;if(n=0) No data!getchar();menu();By1)Staff on work 2)party membern 3)female count 4)Highest qualifications bb4)/*统计在职人员*/ for(i=0,count=0;n&staffi.age;if(strcmp(staffi.category,enteir)!=0&strcmp(staffi.category,linshigong=0)count+; printf_one(staffi);ttttTotal%dmessages,count);else
14、if(w0=)/*统计党员*/ if(strcmp(staffi.p_landscape,party)=0)/*统计女工人员*/ if(strcmp(staffi.sex,femalttttTotal%dmessageelse /*统计高学历人员*/ if(strcmp(staffi.Qualifications,shuoshi)=0|strcmp(staffi.Qualifications,更高n1)Continue to stastic 2)Back to menu 3)Exist bb/*排序模块*/ void sort() int i,j;struct staff s1; n=load();By 1)age 2)Come time bb)/*按年龄排序*/ n-1;i+)/*选择法排序*/ for(j=i+1;jstaffj.age) s1=staffi;staffi=staffj;staffj=s1;else /*按来院时间排序*/ if(strcmp(e_time,e_time)0) i+) /*显示排序结果*/ n1)Back tomenu 2)Continue 3)Exist bb) menu();/*浏览模块*/ void browse() n ;ttttTatal( %d)messagen,n); 1)Back to m
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1