资源描述:
《简单学生信息管理.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include//#includestructdoubly{charname[15];/*longintnumber[10];*//’modifiedbyhuanmie*/longnumber;structdoubly*lLinkj*rLink;};structdoubly*record*head*tail*temp2;chartempi;intflag;/*函数声明*//*计算当前链表节点数*/intelem_num();/*显示当前链表
2、节点*/voiddisplay();/*删除节点元素*/voiddeletetion();/*插入节点元素*/voidinsertion();voidmain()(FILE*inFileJ*outFile;charkey;charfilename[20];charans^respond;head=(structdoubly*)malloc(sizeof(structdoubly));head->lLink=head->rLink=NULL;record=head;do{flag=0;printf("enterthenameofthefiletha
3、tyouwanttoopenH);scanf(yfilename);printf(,,filename=%s,,Jfilename);if((inFile=fopen(filenameJ"rt"))==NULL)(printf(f,error11);getch();flag=l;})while(flag!=0);printf(u/*while(fscanf(inFile?record->name,record->number)!=EOF)*//*modifiedbyhuanmie*/while(l)(//printf("readele
4、m..");tail=(structdoubly*)malloc(sizeof(structdoubly));i千(fscanflinFile,&tail->number)==EOF)(break;}/*head->rLink=tail;tail->lLink=head;*/record->rLink=tail;—modifiedbyhuanmie,新节点插入到当前链表尾*/tail->lLink=record;tail->rLink=NULL;record=tail;}/*head->lLink=record->lLink;record->
5、lLink->rLink=head;*/head->lLink=record;/*modifiedbyhuanmie,形成循环链表*/record->rLink=head;fclose(inFile);printf(n己关闭只读文件An");/*ans='';*//*modifiedbyhuanmie,空字符常量*/ans='N';while(ans!=lY,){do(printf(flI->insertD->deleteS->showQ->quitH);printf(,fenteryouchoiceI-Q,f);/*scan
6、f(”%c”,&ans);*/scanf(n%c”,&ans);/*modifiedbyhuanmie*/switch(ans)(case•I*:printf("insertion");insertion();break;/*modifiedbyhuanmie*/case'D':printf(Hdeletetion");deletetion();break;/*modifiedbyhuanmie*/case'S':printf("shown);display();break;/*modifiedbyhuanmie*/case'Q':p
7、rintf(,,quitH);/*exit(l);*/break;/*modifiedbyhuanmie*/default:break;}}while(ans!='Q');printf("areyousuretoquit?(Y/N)");/*scanf(,,%cH,&ans);*/scanf("%c”,&ans);/*modifiedbyhuanmie*/printf(un“);}printf("filehasbeenchanged,SAVEandEXIT?[YorN]H);fflush(stdin);"modifiedbyhuanm
8、ie*/key=getchar();switch(key)(case'Y':outFile=fopen(filenamej”wt'');