内容发布更新时间 : 2024/11/2 19:31:47星期一 下面是文章的全部内容请认真阅读。
else if (i>=3&&i<=12&&j>=5&&j<=76) cprintf(\ else printf(\ } } gotoxy(32,4); textcolor(BLACK); cprintf(\ gotoxy(31,14); cprintf(\ System -- BY GK\ for(i=0;i<7;i++) /*显示菜单*/ { gotoxy(34,i+6); cprintf(\ } }
void PrintPause() /*暂停*/ { printf(\ getch(); }
void Guangtiao(int flag) /*定义画光条的函数*/ { char list[7][20]={\ \ \ \ \ \ \ gotoxy(34,flag+5); textcolor(WHITE); textbackground(BLACK); cprintf(\ textcolor(LIGHTGRAY); }
int Add() /*添加信息*/ { WORKERBASIC new; FILE *fp=NULL; char ch='y'; while(ch=='y') {
cleanscreen(); printf(\ scanf(\ getchar(); printf(\ scanf(\ getchar(); printf(\ scanf(\ getchar(); if((fp=fopen(\ { fp=fopen(\ } if(fwrite(&new,sizeof(WORKERBASIC),1,fp)!=1) { printf(\ PrintPause(); } fclose(fp); printf(\ scanf(\ } return 0; }
int Scan() /*查看信息*/ { WORKERBASIC load; FILE *fp=NULL; int n=0; cleanscreen(); if((fp=fopen(\ { printf(\ PrintPause(); return 0; } printf(\ printf(\ while(!feof(fp)) { if (fread(&load,sizeof(WORKERBASIC),1,fp)==1) n++; else
break; printf(\ } printf(\ printf(\ fclose(fp); PrintPause(); return 0; }
void exchange(WORKERBASIC *max,WORKERBASIC *min) /*调换两个职工在数组中的位置*/ { WORKERBASIC t; strcpy(t.name,max->name); t.No=max->No; strcpy(max->name,min->name); max->No=min->No; strcpy(min->name,t.name); min->No=t.No; }
int EditByNo(WORKERBASIC *F1,int n) /*按编号查找*/ { int i,j,k,num,high,low,mid,flag=0; for(i=0;i
(F1+i*sizeof(WORKERBASIC))->name); printf(\ printf(\ scanf(\ getchar(); low=0; /*折半法*/ high=n-1; while((low<=high)&&(flag==0)) { mid=(low+high)/2; if (num>((F1+mid*sizeof(WORKERBASIC))->No)) low=mid+1; else if (num<((F1+mid*sizeof(WORKERBASIC))->No)) high=mid-1; else if (num==((F1+mid*sizeof(WORKERBASIC))->No)) flag=1; } if (flag==0) { printf(\ } else { printf(\ printf(\ printf(\ORKERBASIC))->age, (F1+mid*sizeof(WORKERBASIC))->name); printf(\ } PrintPause(); return 0; }
int EditByName(WORKERBASIC *F1,int n) /*按姓名查找*/ { char str[20]; int i,j,k,flag=0,low,high,mid; for(i=0;i if (strcmp( (F1+k*sizeof(WORKERBASIC))->name, (F1+j*sizeof(WORKERBASIC))->name )>0) { k=j; } } if (k!=i) exchange((F1+i*sizeof(WORKERBASIC)),(F1+k*sizeof(WORKERBASIC))); } /*此显示信息只为说明职工已按名字排序,该部分可删除*/ printf(\ printf(\ for(i=0;i