




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
獨燧工亭院程序設計課程設計報告課題名稱:學生籍貫信息記錄簿專業(yè)計算機科學與技術(shù)(軟件工程)學生姓名指導教師完成日期課程設計的目的-1設計內(nèi)容與要求-1TOC\o"1-5"\h\z\o"CurrentDocument"主要技術(shù)指標及特點13.0信息描述(注:用流程圖表示)1\o"CurrentDocument"創(chuàng)建信息鏈表并以磁盤文件保存;2\o"CurrentDocument"讀取磁盤文件并顯示輸出所有學生的籍貫信息;3\o"CurrentDocument"按學號或姓名查詢其籍貫;5\o"CurrentDocument"按籍貫查詢并輸出該籍貫的所有學生;9\o"CurrentDocument"能添加、刪除和修改學生的籍貫信息;11\o"CurrentDocument"顯示輸出江蘇籍和非江蘇籍學生的信息并可分別存盤。16設計小結(jié)17程序源代碼18參考文獻—29二課程設計的目的加深對《C語言程序設計》課程知識的理解,掌握c語言應用程序的開發(fā)方法和步驟;進一步掌握和利用C語言進行課程設計的能力;進一步理解和運用結(jié)構(gòu)化程序設計的思想和方法;初步掌握開發(fā)一個小型實用系統(tǒng)的基本方法;學會調(diào)試一個較長的程序的基本方法;學會利用流程圖或N-S圖表示算法;掌握書寫課程設計開發(fā)文檔的能力(書寫課程報告)。設計內(nèi)容與要求編制一個學生籍貫信息記錄簿,每個學生信息包括:學號、姓名、籍貫。具體功能要求如下:創(chuàng)建信息鏈表并以磁盤文件保存;讀取磁盤文件并顯示輸出所有學生的籍貫信息;按學號或姓名查詢其籍貫;按籍貫查詢并輸出該籍貫的所有學生;能添加、刪除和修改學生的籍貫信息;顯示輸出江蘇籍和非江蘇籍學生的信息并可分別存盤。主要技術(shù)指標及特點3.0信息描述(注:用流程圖表示)建立鏈表3.1創(chuàng)建信息鏈表并以磁盤文件保存;/個***************************************************/structhj{longnumber;charname[10],address[50];structhj*next;};/*********************文件操作函數(shù)******************************/FILE*fp;voidopenfile(charxx[20]){fp=fopen(xx,〃ab+〃);if(fp==NULL)fp=fopen(xx,〃wb〃);}********************************************************intmain(intargc,char*argv[]){begin:intt;system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★\n\n\n\n\n");printf("一錄入學生籍貫信息\n\n〃);printf("二查編學生籍貫信息\n\n〃);錯誤的選擇,請重新選擇:錯誤的選擇,請重新選擇:");printf("printf("printf("mm:scanf(〃%d〃,&t);switch(t){case1:hjnew();break;case2:hjselect();break;case3:hjde();break;case4:exit(0);default:printf("\n
gotomm;}gotobegin;return0;}三刪除學生籍貫信息\n\n〃);四退出程序\n\n〃);請您選擇:");-JOJ★★共★★歡迎使用戶籍莒理系蝙★★★★★-錄入字生箱貫侑息-圳瞭學生藉頁信息四退出程序請您選庠;3.2讀取磁盤文件并顯示輸出所有學生的籍貫信息;voidallselect(chara[8])//全部查詢{intn=0;intk=0;system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);printf("\n★★★籍貫方式信息★★★\n\n\n〃);structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(a,〃rb〃);if(fp==NULL){printf("\n對不起,沒有記錄無法查詢!〃);gotoxxxx;}rewind(fp);while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;elseq->next=p;q=p;}q->next=NULL;structhj*h1,*p2,*q3,*r4,*s5;h1=p2=(hj*)malloc(sizeof(structhj));p2->next=head;while(p2->next!=NULL){q3=p2->next;r4=p2;while(q3->next!=NULL){if(q3->next->number<p2->next->number)r4=q3;q3=q3->next;}if(r4!=p2){s5=r4->next;r4->next=s5->next;s5->next=p2->next;p2->next=s5;}p2=p2->next;}head=h1->next->next;free(h1);p=head;while(p!=NULL&&n>0){n--;printf("\n學號=%ld姓名=%s",p->number,p->name);printf("\n地址=%s",p->address);p=p->next;}xxxx:printf("\n一顯示完畢一\n⑴f返回上級菜單⑵1退出程序\n請選擇:〃);xxx:scanf(〃%d〃,&n);switch(n){case1:break;case2:exit(0);default:printf(〃\n錯誤的選擇,請重新選擇:〃);gotoxxx;}}voidhjselect(void)//查詢編輯信息函數(shù){cxbegin:inta;system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/)printf("\n★★★查詢編輯信息★★★\n\n\n〃);printf("\n一按學號力式查詢\n);printf("\n二按姓名方式查詢\n);printf("\n三按籍貫力式查詢\n);printf("\n四—顯示全部信息偵);printf("\n五—返回上級菜單\n〃);printf("\n請選擇查詢方式:");cxmm:scanf(〃%d〃,&a);switch(a){case1:hjxmselect();gotocxbegin;break;case2:hjxhselect();gotocxbegin;break;case3:hjjgselect();gotocxbegin;break;case4:allselect(〃hj.txt〃);gotocxbegin;break;case5:break;default:printf(〃\n錯誤的選擇,請重新選擇:〃);gotocxmm;}}
,■D:yjmgraiiiFiles^liurctwcjHVSeuhISiudid★★★★★歡迎使用尸藉管理系統(tǒng)查詢翳再信息★★★按學號方式查澗按姓名方式查詢技籍胃方式吉詢f筮示全部信息-返回上繆萊差請選擇查詢方式!3.3按學號或姓名查詢其籍貫;/******************************************************/voidhjxmselect(void)//按學號方式查詢函數(shù){ssmmx:intn=0;longhh;★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★'/);★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★'/);★★★查詢編輯信息★★★'/);=提示輸入0返回上級菜單=\n\n\n〃);請您輸入學號:");printf("\nprintf("\nprintf("\nprintf("scanf(〃%ld〃,&hh);if(hh!=0){structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(〃hj.txt〃,〃rb〃);if(fp==NULL){printf("\n沒有記錄,請輸入記錄然后再查詢!〃);getch();gotojjx;}while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)
head=p;elseq->next=p;q=p;}q->next=NULL;p=head;while(p!=NULL){if(p->number==hh){inta;學號=%ld姓名學號=%ld姓名=%s",p->number,p->name);地址=%s",p->address);⑴更改數(shù)據(jù)⑵刪除數(shù)據(jù)⑶查詢其他數(shù)據(jù)⑷返printf("\nprintf("\n\n操作回上頁⑸退出程序\n\n請您選擇操作:〃);ssmx:scanf(〃%d〃,&a);switch(a){voidhjedit(structhj*headd,structhj*pp);voidhjdelete(structhj*headdd,structhj*ss);case1:hjedit(head,p);gotossmmx;break;case2:hjdelete(head,p);gotossmmx;break;case3:gotossmmx;case4:gotojjx;case5:exit(0);default:printf("\n錯誤的選擇,請重新選擇:〃);gotossmx;}}elsep=p->next;}intiiii=0;printf("\n沒有此記錄1.重新查詢2.返回上一頁3.退出程序!〃);printf("\n請選擇:〃);qqqq:scanf(〃%d〃,&iiii);switch(iiii){case1:gotossmmx;case2:gotojjx;case3:exit(0);default:printf("\n錯誤的選擇,請重新選擇:〃);gotoqqqq;}gotojjx;
jjx:;}S3EETSESlEEIi★歡迎使用戶藉管理系統(tǒng)★★★★去★★★查洵編輯?隹皂★★上二提示輸入0返回上級菜單二jjx:;}S3EETSESlEEIi結(jié)是T?學號』姓備沈南地11=江蘇操作-[I]更改數(shù)據(jù)⑵刪隧數(shù)據(jù)⑶否詢其他鼓據(jù)[4〕遺口上頁伍〕退出程序請尊選擇操作:voidhjxhselect(void)//按姓名方式查詢函數(shù){ssmm:intn=0;charhh[10];★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);★★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);★★★查詢編輯信息★★★'/);=提示輸入0返回上級菜單=\n\n\n〃);請您輸入姓名:");printf("\nprintf("\nprintf("\nprintf("scanf(〃%s〃,hh);if(strcmp(hh,〃0〃)!=0){structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(〃hj.txt〃,〃rb〃);if(fp==NULL){printf("\n沒有記錄,請輸入記錄然后再查詢!〃);getch();gotojjj;}while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;elseq->next=p;q=p;}q->next=NULL;p=head;while(p!=NULL)if(strcmp(p->name,hh)==0){inta;printf("\n結(jié)果一學號=%ld姓名=%s〃,p->number,p->name);printf("\n地址=%s〃,p-〉address);printf(-\n\n操作一⑴更改數(shù)據(jù)⑵刪除數(shù)據(jù)⑶查詢其他數(shù)據(jù)⑷返回上頁⑸退出程序\n\n請您選擇操作:〃);ssm:scanf(〃%d〃,&a);switch(a){voidhjedit(structhj*headd,structhj*pp);voidhjdelete(structhj*headdd,structhj*ss);case1:hjedit(head,p);gotossmm;break;case2:hjdelete(head,p);gotossmm;break;case3:gotossmm;case4:gotojjj;case5:exit(0);default:printf("\n錯誤的選擇,請重新選擇:〃);gotossm;}}elsep=p-〉next;}intiii=0;printf("\n沒有此記錄1.重新查詢2.返回上一頁3.退出程序!〃);printf("\n請選擇:〃);qqq:scanf(〃%d〃,&iii);switch(iii){case1:gotossmm;case2:gotojjj;case3:exit(0);default:printf(-\n錯誤的選擇,請重新選擇:");gotoqqq;}gotojjj;}jjj:;}
★★去★★歡迎使.用戶籍皆理系統(tǒng)★★★★★★★★查洵編輯信皂★★★=提示輸2■展返回上級菜單=請您前入姓茗,顧征糧結(jié)果…蠢*工蘇姓名頂征根操作--⑴更改數(shù)據(jù)也圓除數(shù)雷⑶查詢其曲莪據(jù)Q返回上頁151退出程J序福您選擇操作::3.4按籍貫查詢并輸出該籍貫的所有學生;voidhjjgselect(void)//按籍貫方式查詢{yyy:inti;system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/)printf("\n★★★籍貫方式查詢信息★★★\n\n\n〃);printf("\n一顯示所有信息\n〃);顯示江蘇籍所有信息\n顯示江蘇籍所有信息\n〃);顯示其它籍所有信息\n〃);自定義查詢信息\n〃);—返回上級菜單\n〃);1退出程序\n〃);請選擇:");printf("\nprintf("\nprintf("\nprintf("\nprintf("\n\nscanf(〃%d〃,&i);switch(i){voidzdyselect(void);voidallselect(chara[8]);case1:allselect(〃hj.txt〃);gotoyyy;break;case2:allselect(〃schj.txt〃);gotoyyy;break;case3:allselect(〃qthj.txt〃);gotoyyy;break;case4:zdyselect();case5:break;case6:exit(0);}}voidzdyselect(void){ssmmz:intn=0,j=0;charhh[10];system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);printf("\n★★★自定義查詢信息★★★\n\n\n〃);printf(-請您輸入地址關(guān)鍵字:");scanf(〃%s〃,hh);if(strcmp(hh,〃0〃)!=0){structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(〃hj.txt〃,〃rb〃);if(fp==NULL){printf("\n沒有記錄,請輸入記錄然后再查詢!〃);getch();gotojjz;}while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;elseq->next=p;q=p;}q->next=NULL;p=head;while(p!=NULL){if(strstr(p->address,hh)!=NULL){inta;j++;printf("\n結(jié)果一學號=%ld姓名=%s〃,p-〉number,p-〉name);printf("\n地址=%s〃,p-〉address);printf("\n\n操作一⑴更改數(shù)據(jù)⑵刪除數(shù)據(jù)⑶查詢下一條數(shù)據(jù)⑷返回上頁⑸退出程序\n\n請您選擇操作:〃);ssmz:scanf(〃%d〃,&a);switch(a){voidhjedit(structhj*headd,structhj*pp);voidhjdelete(structhj*headdd,structhj*ss);case1:hjedit(head,p);gotossmmz;break;case2:hjdelete(head,p);gotossmmz;break;case3:p=p->next;continue;case4:gotojjz;case5:exit(0);default:printf("\n錯誤的選擇,請重新選擇:〃);gotossmz;}p=p->next;}elsep=p->next;}if(j==0){printf("\n\n\n沒有匹配的記錄按任意鍵繼續(xù)!〃);getch();fclose(fp);gotossmmz;}else{intxx;printf("\n\n查詢完畢?、爬^續(xù)查詢⑵返回上一級菜單⑶退出程序");printf(〃\n請選擇:〃);scanf(〃%d〃,&xx);if(xx==2)gotojjz;elseif(xx==3)exit(0);}gotossmmz;jjz:;}歡迎僥用戶藉管理系統(tǒng)★★★★★★★★自定義查詢佶息★★女請您輸入地址關(guān)鍵宇:山京結(jié)果一蠢方姓名湖世鵬操作T[Il更改數(shù)據(jù)⑵地除數(shù)據(jù)⑶查詢下一條數(shù)舞囹返回上頁lid退出程序請您,選擇操作:3.5能添加、刪除和修改學生的籍貫信息;/**********************錄入信息函數(shù)**************************/voidhjnew(void){system(〃cls〃);intn=0;longxnumber;charxname[10];charxaddress[50];structhj*head;structhj*x1,*x2;head=NULL;x2=NULL;printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);printf("\n★★★錄入信息★★★'/);printf("\n=提示輸入0返回上級菜單=\n\n\n〃);printf("\n請輸入學號【15字內(nèi)】:〃);scanf(〃%ld〃,&xnumber);if(xnumber==0)gotohaha;printf("\n請輸入姓名【10字內(nèi)】:〃);scanf(〃%s〃,xname);printf(-\n請輸入籍貫【25字內(nèi)】:");scanf(〃%s〃,xaddress);while(xnumber!=0){n++;x1=(structhj*)malloc(sizeof(structhj));x1->number=xnumber;strcpy(x1->name,xname);strcpy(x1->address,xaddress);if(n==1)head=x1;elsex2->next=x1;x2=x1;printf("\n請輸入學號【15字內(nèi)】:〃);scanf(〃%ld〃,&xnumber);if(xnumber==0)break;printf("\n請輸入姓名【10字內(nèi)】:〃);scanf(〃%s〃,xname);printf(-\n請輸入籍貫【25字內(nèi)】:");scanf(〃%s〃,xaddress);}x2->next=NULL;x1=head;while(x1!=NULL){
openfile(〃hj.txt〃);chard[5]="江蘇〃;fwrite(x1,sizeof(structhj),1,fp);fclose(fp);if(strstr(x1->address,d)!=NULL){openfile(〃schj.txt〃);fwrite(x1,sizeof(structhj),1,fp);fclose(fp);}else{openfile(〃qthj.txt〃);fwrite(x1,sizeof(structhj),1,fp);fclose(fp);}x1=x1->next;}haha:;號由字內(nèi)】:1haha:;號由字內(nèi)】:1請輸入姓名[1日字內(nèi)】,由茹*判1入籍貫玨s字內(nèi)】:江蘇請輸入學號W字內(nèi)】;3S南入姓名口9字內(nèi)】:【前征根請輸入籍貫匚器字內(nèi)】;江蘇:輸入學號口5字內(nèi)】=3請翰入姓名旦H字內(nèi)】=虞更興S融入籍貫應5字內(nèi)]:江蘇請餉入學號W字內(nèi)】=4請瑜入姓名口日字內(nèi)】.祝世鵬請餉入箱貫1器字內(nèi)】:山東cxxbegin:inta;system(〃cls〃);printf("\nprintf("\nprintf("\nprintf("\nprintf("\nprintf("\nvoidhjde(void)//刪除界面函數(shù){★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);★★★刪除信息★★★\n\n\n〃);按學號方式刪除\n〃);按姓名方式刪除\n〃);cxxbegin:inta;system(〃cls〃);printf("\nprintf("\nprintf("\nprintf("\nprintf("\nprintf("\nprintf("\n五一返回上級菜單\n〃);printf("\n請選擇刪除方式:〃);cxxmm:scanf(〃%d〃,&a);inti=0;switch(a){case1:hjxmselect();gotocxxbegin;break;case2:hjxhselect();gotocxxbegin;break;case3:zdyselect();gotocxxbegin;break;case4:fp=fopen(〃hj.txt〃,〃wb〃);if(fp!=NULL)i++;fp=fopen(〃schj.txt〃,〃wb〃);if(fp!=NULL)i++;fp=fopen(〃qthj.txt〃,〃wb〃);if(fp!=NULL)i++;if(i==3){printf("\n全部數(shù)據(jù)已經(jīng)刪除!!!!!!敲任意鍵繼續(xù)");getch();}gotocxxbegin;break;case5:break;default:printf(〃\n錯誤的選擇,請重新選擇:〃);gotocxxmm;}}//==============刪除函數(shù)接口===============voidhjdelete(structhj*headdd,structhj*ss){structhj*q;chard[5]=〃江蘇〃;if(headdd==ss){headdd=headdd->next;gotogogo;}q=headdd;while(q!=NULL){if(q->next->number==ss->number){break;}q=q->next;}q->next=ss->next;gogo:q=headdd;fp=fopen(〃hj.txt〃,〃wb〃);while(q!=NULL){fwrite(q,sizeof(structhj),1,fp);q=q->next;}fclose(fp);q=headdd;fp=fopen(〃schj.txt〃,〃wb〃);while(q!=NULL){if(strstr(q->address,d)!=NULL){fwrite(q,sizeof(structhj),1,fp);}q=q->next;}fclose(fp);q=headdd;fp=fopen(〃qthj.txt〃,〃wb〃);while(q!=NULL){if(strstr(q->address,d)==NULL){fwrite(q,sizeof(structhj),1,fp);}q=q->next;}fclose(fp);}//===============編輯函數(shù)接口==============voidhjedit(structhj*headd,structhj*pp){intn=0;structhj*p,*p1,*p2;chard[5]=〃江蘇〃;printf("\n輸入一學號=");scanf(〃%ld〃,&pp-〉number);printf("\n姓名=");scanf(〃%s〃,pp->name);printf("\n地址=");scanf(〃%s〃,pp->address);p=headd;fp=fopen(〃hj.txt〃,〃wb〃);while(p!=NULL){fwrite(p,sizeof(structhj),1,fp);p=p->next;}fclose(fp);p1=headd;fp=fopen(〃schj.txt〃,〃wb〃);while(p1!=NULL){if(strstr(p1->address,d)!=NULL){fwrite(p1,sizeof(structhj),1,fp);p1=p1->next;}fclose(fp);p2=headd;fp=fopen(〃qthj.txt〃,〃wb〃);while(p2!=NULL){if(strstr(p2->address,d)==NULL){fwrite(p2,sizeof(structhj),1,fp);}p2=p2->next;}fclose(fp);}唇3.=E★★歡迎使用戶籍管理.系統(tǒng)★食★★★查詢編揖信息★★★=提示輸入旦密回上級菜單=請您椅入學號:2結(jié)果f學號=8理名=顧征根操作-III更改數(shù)據(jù)⑵刪除數(shù)據(jù)⑶登詢其■他裁弟囹返回二頁⑸退出程序請您選擇操作以
QI-InJ★★婦t★跋迎使用戶籍置理系統(tǒng)★★★★★★★決查詢編苗信.目二提示輸入H返回上級菜單=清您瑜入學號:2膏耳普記柔L重新查詢項回上一頁3.退出程序T3.6顯示輸出江蘇籍和非江蘇籍學生的信息并可分別存盤。voidhjjgselect(void)//按籍貫方式查詢{yyy:inti;system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/)printf("\n★★★籍貫方式查詢信息★★★\n\n\n〃);顯示所有信息\n顯示所有信息\n〃);顯示江蘇籍所有信息\n〃);顯示其它籍所有信息\n〃);自定義查詢信息\n〃);—返回上級菜單\n〃);1退出程序\n〃);請選擇:");printf("\nprintf("\nprintf("\nprintf("\nprintf("\nprintf("\n\nscanf(〃%d〃,&i);switch(i){voidzdyselect(void);voidallselect(chara[8]);case1:allselect(〃hj.txt〃);gotoyyy;break;case2:allselect(〃schj.txt〃);gotoyyy;break;case3:allselect(〃qthj.txt〃);gotoyyy;break;case4:zdyselect();case5:break;case6:exit(0);}}★★衣★★歡迎使用.戶籍管理系統(tǒng)★★丸★★★★★自定義查詢治息★★★請您輸入地址關(guān)鍵字:山京結(jié)果-靠航嚴祝世鵬操作一〔II更改數(shù)據(jù)區(qū)壩除數(shù)據(jù)⑴查詢下一條數(shù)苗即透回上頁IS退出程序清冬選擇操作:設計小結(jié)課程設計是培養(yǎng)學生綜合運用所學知識、發(fā)現(xiàn)、提出、分析和解決實際問題,鍛煉實踐能力的重要環(huán)節(jié),是對學生實際工作能力的具體訓練和考察過程。隨著科學技術(shù)的發(fā)展,當今計算機存活在世界的每一個角落。因此,作為二十一世紀的大學生來說,掌握計算機開發(fā)技術(shù)是非常正要的。對于此次課程設計,感慨頗多。的確,從拿到題目到完成整個編程,從理論到實踐,在兩周時間里,可以學到很多很多的東西,同時不僅可以鞏固以前所學過的知識,還學到了許多書本上沒有的知識。通過這次課程設計,我懂得了理論與實踐相結(jié)合是很重要的,只有理論知識是遠遠不夠的,只有把所學的理論知識和實踐相結(jié)合起來,從理論中得出結(jié)論,才能真正的提高自己的實際動手能力和獨立思考的能力,才能真正的為社會服務。在設計過程中,可以說是困難重重,畢竟很久沒有接觸過C語言了,很多基礎(chǔ)知識都忘記了,難免會遇到各種各樣的問題,比如scanf每加&或缺少}之類的小錯誤都要花很長時間找出來,另外對文件的讀寫等操作以前一直不大清楚,這次課程設計中包含了許多對文件的操作,使我對文件操作的能力有了很大的提高。正所謂:溫故而知新!兩周的課程設計結(jié)束了,期間遇到了很多問題,這次設計在老師和同學的指導與幫助下、查閱資料以及借鑒網(wǎng)上原有的同類程序代碼得以完成。我也意識到自己掌握的知識還很缺陷,在以后的課程學習中,我要更加認真仔細,全面地了解相關(guān)知識。五.程序代碼#include"dos.h"#include"stdio.h"#include#include#include#include"stdlib.h”〃一一一.一1一〃
conio.h"math.h”"string.h"/個***************************************************/structhj{longnumber;charname[10],address[50];structhj*next;};、,/********************文件操作函數(shù)******************************/FILE*fp;voidopenfile(charxx[20]){fp=fopen(xx,〃ab+〃);if(fp==NULL)fp=fopen(xx,〃wb〃);}/**************錄入信息函數(shù)***********************************/voidhjnew(void){system(〃cls〃);intn=0;longxnumber;charxname[10];charxaddress[50];structhj*head;structhj*x1,*x2;head=NULL;x2=NULL;printf("\nprintf("\nprintf("\nprintf("\nscanf(〃%ld〃,&xnumber);if(xnumber==0)gotohaha;printf("\nscanf(〃%s〃,xname);printf("\nscanf(〃%s〃,xaddress);while(xnumber!=0)★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);★★★錄入信息*★★'/);=提示輸入0返回上級菜單=\n\n\n〃);
請輸入學號【15字內(nèi)】:");請輸入姓名【10字內(nèi)】:");請輸入籍貫【25字內(nèi)】:");n++;x1=(structhj*)malloc(sizeof(structhj));x1->number=xnumber;strcpy(x1->name,xname);strcpy(x1->address,xaddress);if(n==1)head=x1;elsex2->next=x1;x2=x1;printf("\n請輸入學號【15字內(nèi)】:〃);scanf(〃%ld〃,&xnumber);if(xnumber==0)break;printf("\n請輸入姓名【10字內(nèi)】:〃);scanf(〃%s〃,xname);printf(-\n請輸入籍貫【25字內(nèi)】:");scanf(〃%s〃,xaddress);}x2->next=NULL;x1=head;while(x1!=NULL){openfile(〃hj.txt〃);chard[5]="江蘇〃;fwrite(x1,sizeof(structhj),1,fp);fclose(fp);if(strstr(x1->address,d)!=NULL){openfile(〃schj.txt〃);fwrite(x1,sizeof(structhj),1,fp);fclose(fp);}else{openfile(〃qthj.txt〃);fwrite(x1,sizeof(structhj),1,fp);fclose(fp);}x1=x1->next;}haha:;}******************************************************voidhjxmselect(void)//按學號方式查詢函數(shù){ssmmx:intn=0;longhh;
system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);printf("\n★★★查詢編輯信息★★★'/);printf("\n=提示輸入0返回上級菜單=\n\n\n〃);printf("請您輸入學號:〃);scanf(〃%ld〃,&hh);if(hh!=0){structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(〃hj.txt〃,〃rb〃);if(fp==NULL){printf("\n沒有記錄,請輸入記錄然后再查詢!〃);getch();gotojjx;}while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;else}q->next=NULL;p=head;}q->next=NULL;p=head;while(p!=NULL){if(p->number==hh){inta;printf("\n結(jié)果一printf("\nprintf("\n\n操作一學號=%ld姓名=%s〃,p-〉number,p-〉name);地址=%s〃,p-〉address);⑴更改數(shù)據(jù)⑵刪除數(shù)據(jù)⑶查詢其他數(shù)據(jù)⑷返回上頁⑸退出程序\n\n請您選擇操作:〃);ssmx:scanf(〃%d〃,&a);switch(a){hjedit(structhj*headd,structhj*pp);hjdelete(structhj*headdd,structhj*ss);1:hjedit(head,p);gotossmmx;break;voidvoidcasecase2:hjdelete(head,p);gotossmmx;break;case3:gotossmmx;
case4:gotojjx;hjedit(structhj*headd,structhj*pp);hjdelete(structhj*headdd,structhj*ss);1:hjedit(head,p);gotossmmx;break;退出程序!〃);printf("\n錯誤的選擇,請重新選擇:");沒有此記錄錯誤的選擇,請重新選擇:");沒有此記錄1.重新查詢2.返回上一頁3.請選擇:");scanf(〃%d〃,&iiii);switch(iiii)case1:gotossmmx;case1:gotossmmx;case2:gotojjx;case3:exit(0);default:printf("\ngotoqqqq;錯誤的選擇,請重新選擇:");}gotojjx;}jjx:;}voidhjxhselect(void)//按姓名方式查詢函數(shù){ssmm:intn=0;charhh[10];★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);★★★查詢編輯信息★★★'/);=提示輸入0返回上級菜單=\n\n\n〃);請您輸入姓名:");printf("\nprintf("\nprintf("\nprintf("scanf(〃%s〃,hh);if(strcmp(hh,〃0〃)!=0){structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(〃hj.txt〃,〃rb〃);if(fp==NULL){printf("\n沒有記錄,請輸入記錄然后再查詢!〃);getch();gotojjj;}while(!feof(fp)){
n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;elseq->next=p;q=p;}q->next=NULL;p=head;while(p!=NULL){if(strcmp(p->name,hh)==0){inta;printf("\n結(jié)果一學號=%ld姓名=%s〃,p-〉number,p-〉name);printf("\n地址=%s〃,p-〉address);printf(-\n\n操作一⑴更改數(shù)據(jù)⑵刪除數(shù)據(jù)⑶查詢其他數(shù)據(jù)⑷返回上頁⑸退出程序\n\n請您選擇操作:〃);ssm:scanf(〃%d〃,&a);switch(a){hjedit(structhj*headd,structhj*pp);hjdelete(structhj*headdd,structhj*ss);voidvoidcase1:hjedit(head,p);gotossmm;break;case2:hjdelete(head,p);gotossmm;break;case3:gotossmm;case4:gotojjj;case5:exit(0);錯誤的選擇,請重新選擇:");hjedit(structhj*headd,structhj*pp);hjdelete(structhj*headdd,structhj*ss);錯誤的選擇,請重新選擇:");沒有此記錄1.重新查詢2.返回上一頁3請選擇:");}intiii=0;printf("\n退出程序!〃);printf("\nqqq:scanf(〃%d〃,&iii);switch(iii){case1:gotossmm;case2:gotojjj;case3:exit(0);
default:printf("\ngotoqqq;}gotojjj;}jjj:;}voidhjjgselect(void)//按籍貫方式查詢{yyy:inti;system(〃cls〃);★★★★★★★★歡迎使用戶籍官理系統(tǒng)★★★★★、/);★★★籍貫方式查詢信息★★★\n\n\n〃);顯示所有信息\n〃);顯示江蘇籍所有信息\n〃);顯示其它籍所有信息\n〃);自定義查詢信息\n〃);—返回上級菜單\n〃);1退出程序\n〃);請選擇:");printf("\nprintf("\nprintf("\nprintf("\nprintf("\nprintf("\nprintf("\nprintf("\n\nscanf(〃%d〃,&i);switch(i){voidzdyselect(void);voidallselect(chara[8]);case1:allselect(〃hj.txt〃);gotoyyy;break;case2:allselect(〃schj.txt〃);gotoyyy;break;case3:allselect(〃qthj.txt〃);gotoyyy;break;case4:zdyselect();case5:break;case6:exit(0);}}voidzdyselect(void){ssmmz:intn=0,j=0;charhh[10];system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);printf("\n★★★自定義查詢信息★★★\n\n\n〃);printf(-請您輸入地址關(guān)鍵字:");scanf(〃%s〃,hh);if(strcmp(hh,〃0〃)!=0){structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(〃hj.txt〃,〃rb〃);if(fp==NULL){printf("\n沒有記錄,請輸入記錄然后再查詢!〃);getch();gotojjz;}while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;elseq->next=p;q=p;}q->next=NULL;p=head;while(p!=NULL){if(strstr(p->address,hh)!=NULL){inta;j++;printf("\n結(jié)果一學號=%ld姓名=%s〃,p-〉number,p-〉name);printf("\n地址=%s〃,p-〉address);printf("\n\n操作一⑴更改數(shù)據(jù)⑵刪除數(shù)據(jù)⑶查詢下一條數(shù)據(jù)⑷返回上頁⑸退出程序\n\n請您選擇操作:〃);ssmz:scanf(〃%d〃,&a);switch(a){voidhjedit(structhj*headd,structhj*pp);voidhjdelete(structhj*headdd,structhj*ss);case1:hjedit(head,p);gotossmmz;break;case2:hjdelete(head,p);gotossmmz;break;case3:p=p-〉next;continue;case4:gotojjz;case5:exit(0);default:printf("\n錯誤的選擇,請重新選擇:〃);gotossmz;}p=p-〉next;}elsep=p->next;}if(j==0){printf("\n\n\n沒有匹配的記錄按任意鍵繼續(xù)!〃);getch();fclose(fp);gotossmmz;}else{intxx;printf("\n\n查詢完畢!⑴繼續(xù)查詢⑵返回上一級菜單⑶退出程序");printf(〃\n請選擇:〃);scanf(〃%d〃,&xx);if(xx==2)gotojjz;elseif(xx==3)exit(0);}gotossmmz;jjz:;}}voidallselect(chara[8])//全部查詢{intn=0;intk=0;system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);printf("\n★★★籍貫方式信息★★★\n\n\n〃);structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(a,〃rb〃);if(fp==NULL){printf("\n對不起,沒有記錄無法查詢!〃);gotoxxxx;}rewind(fp);while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;elseq->next=p;q=p;}q->next=NULL;structhj*h1,*p2,*q3,*r4,*s5;h1=p2=(hj*)malloc(sizeof(structhj));p2->next=head;while(p2->next!=NULL){q3=p2->next;r4=p2;while(q3->next!=NULL){if(q3->next->number<p2->next->number)r4=q3;q3=q3->next;}if(r4!=p2){s5=r4->next;r4->next=s5->next;s5->next=p2->next;p2->next=s5;}p2=p2->next;}head=h1->next->next;free(h1);p=head;while(p!=NULL&&n>0){n--;printf("\n學號=%ld姓名=%s",p->number,p->name);printf("\n地址=%s",p->address);p=p->next;}xxxx:printf("\n一顯示完畢一\n⑴f返回上級菜單⑵|退出程序\n請選擇:〃);xxx:scanf(〃%d〃,&n);switch(n){case1:break;case2:exit(0);default:printf(〃\n錯誤的選擇,請重新選擇:〃);gotoxxx;}}voidhjselect(void)//查詢編輯信息函數(shù){cxbegin:inta;system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/)printf("\n★★★查詢編輯信息★★★\n\n\n〃);printf("\n一按字號力式查詢\n);printf("\n一按姓名方式查詢\n);printf("\n三按籍貫力式查詢\n);printf("\n四—顯示全部信息偵);printf("\n五—返回上級菜單\n〃);printf("\n請選擇查詢方式:");cxmm:scanf(〃%d〃,&a);switch(a){case1:hjxmselect();gotocxbegin;break;case2:hjxhselect();gotocxbegin;break;case3:hjjgselect();gotocxbegin;break;case4:allselect(〃hj.txt〃);gotocxbegin;break;case5:break;default:printf(〃\n錯誤的選擇,請重新選擇:〃);gotocxmm;}}voidhjde(void)//刪除界面函數(shù){cxxbegin:inta;system(〃cls〃);printf("\n★★★★★歡迎使用戶籍管理系統(tǒng)★★★★★、/);printf("\n★★★刪除信息★★★\n\n\n〃)printf("\n一按學號方式刪除\n〃);printf("\n二按姓名方式刪除\n〃);printf("\n三按籍貫方式刪除\n〃);printf("\n四一刪除全部信息\n〃);printf("\n五—返回上級菜單\n〃);printf("\n請選擇刪除方式:〃);cxxmm:scanf(〃%d〃,&a);inti=0;switch(a){case1:hjxmselect();gotocxxbegin;break;case2:hjxhselect();gotocxxb
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 推土機租賃合同書
- 建筑工程合同協(xié)議書
- 北京存量房買賣合同
- 總代理合作合同書
- 消防施工施工方案
- 天津改性砂漿施工方案
- TCSHB 0017-2024 生成式人工智能模型訓練合規(guī)技術(shù)規(guī)范
- 足球場地基板施工方案
- 黑龍江草莓大棚施工方案
- 橋梁直角墊板施工方案
- 車庫租賃合同
- 《工程項目審計》課件
- 法人不參與經(jīng)營免責協(xié)議
- 小學生心理健康主題家長會
- QB/T 4031-2024 阻燃性汽車空氣濾紙(正式版)
- DZ∕T 0130-2006 地質(zhì)礦產(chǎn)實驗室測試質(zhì)量管理規(guī)范(正式版)
- 《“光盤”行動-從我做起!》課件
- 杠桿原理及其應用實驗報告總結(jié)
- 2024年高職考試-渤海船舶職業(yè)學院單招筆試參考題庫含答案
- 人教新課標高一數(shù)學必修一講義(上半冊)共7講(無答案)
- 低壓斷路器課件
評論
0/150
提交評論