1、 int insert(LINK p2); int del(LINK p2,int m);/* void creat(); void read();/* void write_fp();/* /*/ void exchange(LINK p1,LINK p2); LINK compare(LINK sp,char dn,char dm);/* LINK bts(LINK sp,LINK p1,LINK p2,char dm);/* LINK stb(LINK sp,LINK p1,LINK p2,char dm); char a; FILE *fp; LINK out_fp; int d,nu
2、m,menu;/*menu if(fp=fopen(C:table.txt,r)=NULL)/* printf(Can not open the file!nNow the program will build a new file!n); fp=fopen(wt+ creat(); out_fp=head; do fprintf(fp,%d %s %s %d %dn,out_fp-data,out_fp-name, out_fp-tel,out_fp-age,out_fp-scoure); out_fp=out_fp-next; while(out_fp!=head); fclose(fp)
3、;/* else read(); output(head);/*/ do /*Command menu list*/n1.Searchn2.Insertn3.Deleten4.Arrangementn0.Exitn/* printf(Please select an option: a=getch();%cn,a); if(a=1) break; else if(a=2340 exit(1); else menu=1; while(menu); /*/ if(a= char dm,dn;Order of (1.name 2.scoure)?: dm=getch();,dm); if(dm=)|
4、(dm=)Order from (1.big to small 2.small to big)? dn=getch();,dn); if(dn=)|(dn= head=compare(head,dn,dm); else Invalid Options! else output(head); /*/Save to the file?(y/n):y write_fp(); printf(Save complete! n read(); while(a!=)&(a!);Order again? num=1; num=0;menu=1; while(num); read();/*/ else if(a
5、= printf(Please enter the items you want to search:n(1.name 2.tel 3.age 4.scoure):Options:/* fflush(stdin);/*IO d=getch();,d); search(head,(char)d); doSearch again? a=getch(); if(a= num=1; num=0; while(a! while(num);/*search*/*/ Insert data? num=insert(head); num=0;/*/ which number do you want to de
6、lete:NO. d=getch(); num=del(head,d); output(head);Delete again? printf( scanf(%d,&d); while(a=getchar()!na!=EOF);/* num=del(head,d); output(head); /*/ write_fp(); menu=0; menu=1; while(menu); exit(1);char search(LINK p,char n)/*/ LINK a=p; char b9; int c; if(n=)|(n=Enter the content: scanf(%s,b); if
7、(strcmp(a-name,b)=0)|(strcmp(a-tel,b)=0)%3d. |%8s|%15s|%8d|%8d|n,a-data, a-name,a-tel,a-age,a- return(0); a=a- while(a!=p);No Datan return(0); else if(n=c); if(a-age=c)|(a-scoure=c) return(0);void output(LINK sp)/*/ int i; sp=head; n num | name | tel | age | scoure |n for(i=1;i+) sp-data=i;/*/,sp- s
8、p-name,sp-tel,sp-age,sp- sp=sp- if(sp=head) break;int insert(LINK p2)/*/ LINK sp,newnode; int i=0; sp=p2-front; newnode=(LINK)malloc(sizeof(struct list); if(newnode=NULL)ERRORn return(1); in_put(newnode); newnode-next=sp- sp-next-front=newnode;front=sp;next=newnode;insert complete! return(1);int del
9、(LINK p2,int m)/* LINK sp; int a,i=0; sp=p2; i+; while(sp! if(m=1) head=head- if(1m)&(m=i) for(a=1;a if(mi)|(mfront=sp- free(sp);delete complete!void creat()/* LINK pb,newnode; for(i=0; newnode=(LINK)malloc(sizeof(struct list); newnode-data=i+1; in_put(newnode); num | name | tel | age | scoure |n,ne
10、wnode-name,newnode-tel,newnode-age,newnode-sure?(press to continue):/* while(a=getch()! if(i=0) pb=head=newnode;head-front=NULL;next=NULL;/* pb-/*front=pb; pb=newnode;nInsert again? if(a=getch()= continue; break; head- pb-next=head;void read()/*/*num fp=fopen( fscanf(fp,newnode-data,& &tel,&age,& pb
11、=head=newnode; /* pb- if(feof(fp)break; head- pb- void write_fp()/* if(fp=fopen()=NULL)/*LINK in_put(LINK p)/*please input the name: scanf(p-name);please input the tel:tel);please input the age: scanf(age);please input the scoure: scanf( return(p);/*/LINK compare(LINK sp,char dn,char dm) LINK p1,p2,p0; p1=p0=sp; p2=p1- if(dn= if(dm= for(;p2!=sp;p2=p2-next) if(strcmp(p2-name,p1-name)0) p1=p2; sp=p1; p0=sp; (p0-next)!p0=p0- p1=p0- p2=p1- for(; if(p0-next!=p1) exchange(p0,p1);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1