资源描述:
《c语言学生通信录管理系统课程设计报告2》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、E、删除voiddel1()开始按电话择调用deltel()按名字择调用delname()按名字或按电话删除结束入口按名字(学号)查找学生第一个节点p1->next=head没找到,输出“notfind!”中间节点p2->next=p1->next结束重建链表用recreact()函数程序清单:1、voiddel1(){inti;printf("
2、---------------------------------
3、");printf("
4、1.deleteintel
5、");printf("
6、
7、2.deleteinname
8、");printf("
9、0.regiter
10、");printf("
11、---------------------------------
12、");do{printf("inputyourchoice");scanf("%d",&i);}while(i!='1'&&i!='2'&i!='0');if(i==1)deltel();elseif(i==2)delname();elseexit(0);}2、voiddelname(){chari;FILE*fp;str
13、uctstudent*p1,*p2,*head;charname[16],c;head=recreat();p1=head;printf("inputthestudent'sname:");scanf("%s",name);while(strcmp(p1->name,name)!=0&&p1->next!=NULL){p2=p1;p1=p1->next;}if(strcmp(p1->name,name)==0){if(p1==head)head=p1->next;elsep2->next=p1
14、->next;printf("deletesuccess!");printf("savethemorno(y/n)");do{printf("inputchoice");getchar();scanf("%c",&i);}while(i!='y'&&i!='Y'&&i!='n'&&i!='N');if(i=='y'
15、
16、i=='Y'){p1=head;if((fp=fopen(FILENAME,"wb"))==NULL){printf("cannotopenfile");retu
17、rn;}if(p1!=NULL)do{if(fwrite(p1,sizeof(structstudent),1,fp)!=1){printf("filewriteerror");fclose(fp);break;}p1=p1->next;}while(p1!=NULL);fclose(fp);exit(0);}}elseprintf("Notfind!");}3、voiddeltel(){chari;FILE*fp;structstudent*p1,*p2,*head;chartel[18
18、],c;head=recreat();p1=head;printf("inputthestudent'stelephonenumber:");scanf("%s",tel);while(strcmp(p1->tel,tel)!=0&&p1->next!=NULL){p2=p1;p1=p1->next;}if(strcmp(p1->tel,tel)==0){if(p1==head)head=p1->next;elsep2->next=p1->next;printf("deletesuccess!
19、");printf("savethemorno(y/n)");do{printf("inputchoice");getchar();scanf("%c",&i);}while(i!='y'&&i!='Y'&&i!='n'&&i!='N');if(i=='y'
20、
21、i=='Y'){p1=head;if((fp=fopen(FILENAME,"wb"))==NULL){printf("cannotopenfile");return;}if(p1!=NULL)do{if(fwrite(
22、p1,sizeof(structstudent),1,fp)!=1){printf("filewriteerror");fclose(fp);break;}p1=p1->next;}while(p1!=NULL);fclose(fp);exit(0);}}elseprintf("Notfind!");}F、修改voidmodify()开始按学号则调用modifynum()按名字则调用modifyname()按名字或按学号找到修改结束入口找到,用scanf函数重新赋值按名字(