include #include #include //#include struct doubly{char name[15];/*long int number[10];*/ /’modified by huanmie*/ long number;struct doubly *lLinkj*rLink;};struct doubly *record*head*tail*temp2;char tempi;int flag;/*函数声明*//*计算当前链表节点数*/int elem_num();/*显示当前链表节点*/void display();/*删除节点元素*/void deletetion();/*插入节点元素*/void insertion();void main()(FILE *inFileJ *outFile;char key;char filename[20];char ans^respond;head=(struct doubly *)malloc(sizeof(struct doubly));head->lLink=head->rLink=NULL;record=head;do{flag=0;printf("enter the name of the file that you want to open\nH); scanf(yfilename);printf(,,filename=%s\n,,J filename);if((inFile=fopen(filenameJ"rt"))==NULL)(printf (f, error\n11);getch();flag=l;}) while(flag!=0);printf(u /*while(fscanf(inFile?record->name,record->number)!=EOF)*//*modified by huanmie*/while(l)(//printf("read elem..\n");tail=(struct doubly *)malloc(sizeof(struct doubly));i千(fscanflinFile,&tail->number)==EOF) ( break;}/*head->rLink=tail;tail->lLink=head;*/record->rLink = tail; —modified by huanmie,新节点插入到当前链表 尾*/tail->lLink=record;tail->rLink=NULL;record=tail;}/*head->lLink=record->lLink;record->lLink->rLink=head;*/head->lLink=record; /*modified by huanmie,形成循环链表*/ record->rLink=head;fclose(inFile);printf (n己关闭只读文件An");/*ans= ; */ /*modified by huanmie,空字符常量*/ans = N;while(ans!=lY,){do(printf(flI->insert\nD->delete\nS->show\nQ->quit\nH); printf(,fenter you choice I-Q\n,f);/*scanf(”%c”,&ans);*/scanf(n %c”, &ans); /*modified by huanmie*/ switch(ans) (case •I*:printf("insertion\n");insertion();break; /*modified by huanmie*/case D:printf(Hdeletetion\n");deletetion();break; /*modified by huanmie*/case S:printf("show\nn);display();break; /*modified by huanmie*/case Q:printf(,,quit\nH);/*exit(l);*/break; /*modified by huanmie*/ default :break;}} while(ans!=Q);printf("are you sure to quit?(Y/N)\n");/*scanf(,,%cH,&ans);*/scanf(" %c”,&ans); /*modified by huanmie*/printf(u n“);}printf("file has been changed ,SAVE and EXIT?[Y or N]\nH); fflush(stdin); "modified by huanmie*/key=getchar();switch(key)(case Y: outFile=fopen(filenamej ”wt);/*record=head;*/ "modified by huanmie,带头节点的双向链表, 保存时跳过头节点*/record = head->rLink;do(千print千(outFile, ”%s %ld\rT,record->name,record->number);/*modified by huanmie*/record=record->rLink;) while(record!=head);fclose(outFile);printf(Hsaving completed!\n,f);break; /*modified by huanmie*/ case N:printf(Hthe chang would not be saved\nn);printf (H \n“);break; default : break; } }/*插入节点元素*/void insertion() /*返I口|值类型*/ { int locate,count; int i;/*record = head;*/ /*modified by huanmie,带头节点的双向链表,保存时 跳过头节点*/record = head->rLink;count=elem_num();do(printf(Henter the location of the inserting element\n,f);scanf("%d"?&locate);}while(locatecount+l);/*for(i=l;irLink;temp2=(struct doubly *)malloc(sizeof(struct doubly));printf(Henter the insert content:H);/*scanf(M%s %ldf, J&temp2->nameJ&temp2->number);*/ /*modified by huanmie*/scanf(!,%s %ldl\temp2->nameJ&temp2->number);record->rLink->lLink=temp2;temp2->rLink=record->rLink;temp2->lLink=record;record->rLink=temp2;return;}/*删除节点元素*/void deletetion()(int county locate;int i;/*char ele_name;long ele_number;*//*record = head;*/ "modified by huanmie,带头节点的双向链表,保存时 跳过头节点*/record = head->rLink;count=elem_num();do(printf(Henter the location of the delete element\nlf);scanf ("%(!" ^locate);)while(locatecount);for(i=0;irLink;/*ele_name=record->name;ele_number=record->number;*/record->lLink->rLink=record->rLink;record->rLink->lLink=record->lLink;free(record);}/*显示当前链表节点*/void display()/*record = head;*/ —modified by huanmie,带头节点的双向链表,保存时 跳过头节点*/record = head->rLink;do(printf(,f%s %ld\nf\record->nameJrecord->number);record=record->rLink;) while(record!=head);return;)/*计算当前链表节点数*/int elem_num(){int count=0;/*record = head;*/ /*modified by huanmie^ 带头节点的双向链表,保存时 跳过头节点*/record = head->rLink;do{record=record->rLink;count++;} while(record != head);return count;。