资源描述:
《双向循环链表68867》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、双向循环链表68867#include"stdio.h"#include"string.h"typedefstructlist*LINK;LINKhead;/*头指针,链表定位*/structlist{intdata;charname[8];chartel[12];intage;intscoure;structlist*front,*next;};FILE*fp;main(){charsearch(LINKp,charn);/*查询*/LINKin_put(LINKp);/*输入函数*/voidou
2、tput(LINKsp);/*输出*/intinsert(LINKp2);/*插入*/intdel(LINKp2,intm);/*删除*/voidcreat();/*输入并创建链表*/voidread();/*读取文件内容*/voidwrite_fp();/*写入文件*//**********************************************************************/voidexchange(LINKp1,LINKp2);/*数据交换*/LINKcomp
3、are(LINKsp,chardn,chardm);/*比较*/LINKbts(LINKsp,LINKp1,LINKp2,chardm);/*从大到小排列*/LINKstb(LINKsp,LINKp1,LINKp2,chardm);/*从小到大排列*//**********************************************************************/chara;FILE*fp;LINKout_fp;intd,num,menu;/*menu菜单控制变量*/i
4、f((fp=fopen("C:\table.txt","r"))==NULL)/*打开或建立文件*/{printf("Cannotopenthefile!Nowtheprogramwillbuildanewfile!");fp=fopen("C:\table.txt","wt+");/*打开文件*/creat();/*创建内容*/out_fp=head;do{fprintf(fp,"%d%s%s%d%d",out_fp->data,out_fp->name,out_fp->tel,
5、out_fp->age,out_fp->scoure);out_fp=out_fp->next;}while(out_fp!=head);fclose(fp);/*关闭文件*/}else{read();/*读取文件*/}output(head);/*输出链表内容*//*************************************************************************************/do{printf("/*****Commandmenulist
6、*****/1.Search2.Insert3.Delete4.Arrangement .Exit");/*主菜单选项,查找,插入,删除,排列,退出*/do{printf("Pleaseselectanoption:");a=getch();printf("%c",a);if(a=='1')break;elseif(a=='2')break;elseif(a=='3')break;elseif(a=='4')break;elseif(a=='0')exit(1);els
7、emenu=1;}while(menu);/*********************************************/if(a=='4'){do{chardm,dn;printf("Orderof(1.name2.scoure)?:");dm=getch();printf("%c",dm);if((dm=='1')
8、
9、(dm=='2')){printf("Orderfrom(1.bigtosmall2.smalltobig)?:");dn=getch();printf("%c
10、n",dn);if((dn=='1')
11、
12、(dn=='2'))head=compare(head,dn,dm);elseprintf("InvalidOptions!");}elseprintf("InvalidOptions!");output(head);/************************************************/do{printf("Savetothefile?(y/n):");a=getch();printf("