《C语言程序设计基础》上机实验报告(模版) 下载本文

内容发布更新时间 : 2024/5/18 21:04:20星期一 下面是文章的全部内容请认真阅读。

PrintPause(); return 0; } printf(\ PrintPause(); return 0; }

int Delete() { WORKER *head=NULL,*t=NULL,*load=NULL,*b=NULL; FILE *fp=NULL; int num; char str[20],ch; cleanscreen(); load=(WORKER *)malloc(sizeof(WORKER)); if((fp=fopen(\ { printf(\ PrintPause(); return 0; } head=t=load; if (fread(load,sizeof(WORKERBASIC),1,fp)!=1) { printf(\ PrintPause(); return 0; } while(!feof(fp)) { load=(WORKER *)malloc(sizeof(WORKER)); t->next=load; if (fread(load,sizeof(WORKERBASIC),1,fp)!=1) break; t=load; } t->next=NULL; fclose(fp); t=head; Scan(); printf(\ printf(\ scanf(\ getchar();

/*删除*/

num=atoi(str); if

((strcmp(t->workerinfo.name,str)==0)||(num==t->workerinfo.No)||(num==t->workerinfo.age)) { printf(\you really want to delete %s?(Press 'y' to sure)\\n\ if ((ch=getch())!='y') return 0; head=t->next; free(t); printf(\ fp=fopen(\ t=head; if (head!=NULL) { fwrite(t,sizeof(WORKERBASIC),1,fp); while(t->next!=NULL) { t=t->next; if(fwrite(t,sizeof(WORKERBASIC),1,fp)!=1) { printf(\ PrintPause(); break; } } } free(head); fclose(fp); PrintPause(); return 0; } while(t->next!=NULL) { t=b; t=t->next; if

((strcmp(t->workerinfo.name,str)==0)||(num==t->workerinfo.No)||(num==t->workerinfo.age)) { printf(\you really want to delete %s?(Press 'y' to sure)\\n\ if ((ch=getch())!='y')

return 0; b->next=t->next; free(t); printf(\ fp=fopen(\ t=head; if (head!=NULL) { fwrite(t,sizeof(WORKERBASIC),1,fp); while(t->next!=NULL) { t=t->next; if(fwrite(t,sizeof(WORKERBASIC),1,fp)!=1) { printf(\ PrintPause(); break; } } } free(head); fclose(fp); PrintPause(); return 0; } b=b->next; } printf(\ PrintPause(); return 0; }

int Into() /*链表插入*/ { WORKER *head=NULL,*t=NULL,*load=NULL,*b=NULL,*a=NULL; FILE *fp=NULL; int num; char str[20],ch; cleanscreen(); load=(WORKER *)malloc(sizeof(WORKER)); if((fp=fopen(\ { printf(\ PrintPause();

return 0; } head=t=load; if (fread(load,sizeof(WORKERBASIC),1,fp)!=1) { printf(\ PrintPause(); return 0; } while(!feof(fp)) { load=(WORKER *)malloc(sizeof(WORKER)); t->next=load; if (fread(load,sizeof(WORKERBASIC),1,fp)!=1) break; t=load; } t->next=NULL; fclose(fp); t=head; Scan(); a=(WORKER *)malloc(sizeof(WORKER)); printf(\ scanf(\ getchar(); printf(\ scanf(\ getchar(); printf(\ scanf(\ getchar(); printf(\ printf(\ scanf(\ getchar(); num=atoi(str); if

((strcmp(t->workerinfo.name,str)==0)||(num==t->workerinfo.No)||(num==t->workerinfo.age)) { printf(\you really want to add before %s?(Press 'y' to sure)\\n\ if ((ch=getch())!='y') return 0;

a->next=t; printf(\ fp=fopen(\ head=t=a; if (head!=NULL) { fwrite(t,sizeof(WORKERBASIC),1,fp); while(t->next!=NULL) { t=t->next; if(fwrite(t,sizeof(WORKERBASIC),1,fp)!=1) { printf(\ PrintPause(); break; } } } free(head); fclose(fp); PrintPause(); return 0; } while(t->next!=NULL) { t=t->next; if

((strcmp(t->workerinfo.name,str)==0)||(num==t->workerinfo.No)||(num==t->workerinfo.age)) { printf(\you really want to add after %s?(Press 'y' to sure)\\n\ if ((ch=getch())!='y') return 0; b->next=t->next; t->next=a; a->next=b->next; printf(\ fp=fopen(\ t=head; if (head!=NULL) { fwrite(t,sizeof(WORKERBASIC),1,fp); while(t->next!=NULL)