學(xué)生籍貫信息記錄簿系統(tǒng)課程設(shè)計(jì)源代碼_第1頁
學(xué)生籍貫信息記錄簿系統(tǒng)課程設(shè)計(jì)源代碼_第2頁
學(xué)生籍貫信息記錄簿系統(tǒng)課程設(shè)計(jì)源代碼_第3頁
學(xué)生籍貫信息記錄簿系統(tǒng)課程設(shè)計(jì)源代碼_第4頁
學(xué)生籍貫信息記錄簿系統(tǒng)課程設(shè)計(jì)源代碼_第5頁
已閱讀5頁,還剩12頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、+64編制一個學(xué)生籍貫信息記錄簿,每個學(xué)生信息包括:學(xué)號、姓名、籍貫。具體功能: (1)創(chuàng)建信息鏈表并以磁盤文件保存; (2)讀取磁盤文件并顯示輸出所有學(xué)生的籍貫信息; (3)按學(xué)號或姓名查詢其籍貫; (4)按籍貫查詢并輸出該籍貫的所有學(xué)生; (5)能添加、刪除和修改學(xué)生的籍貫信息;#include "dos.h"#include "stdio.h"#include "stdlib.h"#include "conio.h"#include "math.h"#include "strin

2、g.h" /*建立鏈表*/struct hj int age; long number; char name10,address50,sex2; struct hj *next;/*文件操作函數(shù)*/FILE *fp;void openfile(char xx20) fp=fopen(xx,"ab+"); if(fp=NULL) fp=fopen(xx,"wb");/*錄入信息函數(shù)*/void hjnew(void) system("cls"); int n=0,xage; long xnumber; char xname10

3、; char xaddress50; char xsex2; struct hj *head; struct hj *x1,*x2; head=NULL; x2=NULL; printf("n 歡迎使用戶籍管理系統(tǒng)n"); printf("n 錄入信息n"); printf("n 提示輸入0返回上級菜單nnn"); printf("n 請輸入學(xué)號【15字內(nèi)】:"); scanf("%ld",&xnumber); if(xnumber=0) goto haha; printf("

4、n 請輸入姓名【10字內(nèi)】:"); scanf("%s",xname); printf("n 請輸入年齡【|-_-|】:"); scanf("%d",&xage); printf("n 請輸入性別【男OR女】:"); scanf("%s",xsex); printf("n 請輸入籍貫【25字內(nèi)】:"); scanf("%s",xaddress); while(xnumber!=0) n+; x1=(struct hj *)malloc(s

5、izeof(struct hj); x1->number=xnumber; strcpy(x1->name,xname); strcpy(x1->sex,xsex); x1->age=xage; strcpy(x1->address,xaddress); if(n=1) head=x1; else x2->next=x1; x2=x1; printf("n 請輸入學(xué)號【15字內(nèi)】:"); scanf("%ld",&xnumber); if(xnumber=0) break; printf("n 請輸入

6、姓名【10字內(nèi)】:"); scanf("%s",xname); printf("n 請輸入年齡【|-_-|】:"); scanf("%d",&xage); printf("n 請輸入性別【男OR女】:"); scanf("%s",xsex); printf("n 請輸入籍貫【25字內(nèi)】:"); scanf("%s",xaddress); x2->next=NULL; x1=head; while(x1!=NULL) openfile

7、("hj.txt"); char d5="四川" fwrite(x1,sizeof(struct hj),1,fp); fclose(fp); if(strstr(x1->address,d)!=NULL) openfile("schj.txt"); fwrite(x1,sizeof(struct hj),1,fp); fclose(fp); else openfile("qthj.txt"); fwrite(x1,sizeof(struct hj),1,fp); fclose(fp); x1=x1->

8、next; haha:;/*查詢函數(shù)*/void hjxmselect(void) /按學(xué)號方式查詢函數(shù)ssmmx: int n=0; long hh; system("cls"); printf("n 歡迎使用戶籍管理系統(tǒng)n"); printf("n 查詢編輯信息n"); printf("n 提示輸入0返回上級菜單nnn"); printf(" 請您輸入學(xué)號:"); scanf("%ld",&hh); if(hh!=0) struct hj *p; struct h

9、j *q=NULL,*head=NULL; fp=fopen("hj.txt","rb"); if(fp=NULL) printf("n沒有記錄,請輸入記錄然后再查詢!"); getch(); goto jjx; while(!feof(fp) n+; p=(struct hj *)malloc(sizeof(struct hj); fread(p,sizeof(struct hj),1,fp); if(n=1) head=p; else q->next=p; q=p; q->next=NULL; p=head; whil

10、e(p!=NULL) if(p->number=hh) int a; printf("n 結(jié) 果 學(xué)號=%ld 姓名=%s 年齡=%d 性別=%s ",p->number,p->name,p->age,p->sex); printf("n 地址=%s",p->address); printf("nn 操 作 更改數(shù)據(jù) 刪除數(shù)據(jù) 查詢其他數(shù)據(jù) 返回上頁 退出程序nn 請您選擇操作:");ssmx: scanf("%d",&a); switch(a) void hjedit(

11、struct hj *headd,struct hj *pp); void hjdelete(struct hj *headdd,struct hj *ss); case 1: hjedit(head,p); goto ssmmx;break; case 2: hjdelete(head,p); goto ssmmx;break; case 3: goto ssmmx; case 4: goto jjx; case 5:exit(0); default:printf("n 錯誤的選擇,請重新選擇:"); goto ssmx; else p=p->next; int i

12、iii=0; printf("n 沒有此記錄 1.重新查詢 2.返回上一頁 3.退出程序!"); printf("n 請選擇:");qqqq: scanf("%d",&iiii); switch(iiii) case 1: goto ssmmx; case 2: goto jjx; case 3: exit(0); default: printf("n 錯誤的選擇,請重新選擇:"); goto qqqq; goto jjx; jjx:;void hjxhselect(void)/按姓名方式查詢函數(shù)ssmm:

13、 int n=0; char hh10; system("cls"); printf("n 歡迎使用戶籍管理系統(tǒng)n"); printf("n 查詢編輯信息n"); printf("n 提示輸入0返回上級菜單nnn"); printf(" 請您輸入姓名:"); scanf("%s",hh); if(strcmp(hh,"0")!=0) struct hj *p; struct hj *q=NULL,*head=NULL; fp=fopen("hj.

14、txt","rb"); if(fp=NULL) printf("n沒有記錄,請輸入記錄然后再查詢!"); getch(); goto jjj; while(!feof(fp) n+; p=(struct hj *)malloc(sizeof(struct hj); fread(p,sizeof(struct hj),1,fp); if(n=1) head=p; else q->next=p; q=p; q->next=NULL; p=head; while(p!=NULL) if(strcmp(p->name,hh)=0) i

15、nt a; printf("n 結(jié) 果 學(xué)號=%ld 姓名=%s 年齡=%d 性別=%s ",p->number,p->name,p->age,p->sex); printf("n 地址=%s",p->address); printf("nn 操 作 更改數(shù)據(jù) 刪除數(shù)據(jù) 查詢其他數(shù)據(jù) 返回上頁 退出程序nn 請您選擇操作:");ssm: scanf("%d",&a); switch(a) void hjedit(struct hj *headd,struct hj *pp);

16、void hjdelete(struct hj *headdd,struct hj *ss); case 1: hjedit(head,p); goto ssmm;break; case 2: hjdelete(head,p); goto ssmm;break; case 3: goto ssmm; case 4: goto jjj; case 5:exit(0); default:printf("n 錯誤的選擇,請重新選擇:"); goto ssm; else p=p->next; int iii=0; printf("n 沒有此記錄 1.重新查詢 2.返

17、回上一頁 3.退出程序!"); printf("n 請選擇:");qqq: scanf("%d",&iii); switch(iii) case 1: goto ssmm; case 2: goto jjj; case 3: exit(0); default: printf("n 錯誤的選擇,請重新選擇:"); goto qqq; goto jjj; jjj: ;void hjjgselect(void)/按籍貫方式查詢yyy: int i; system("cls"); printf("

18、;n 歡迎使用戶籍管理系統(tǒng)n"); printf("n 籍貫方式查詢信息nnn"); printf("n 一 顯示所有信息n"); printf("n 二 顯示四川籍所有信息n"); printf("n 三 顯示其它籍所有信息n"); printf("n 四 自定義查詢信息n"); printf("n 五 返回上級菜單n"); printf("n 六 退出程序n"); printf("nn 請選擇:"); scanf(&quo

19、t;%d",&i); switch(i) void zdyselect(void); void allselect(char a8); case 1:allselect("hj.txt"); goto yyy;break; case 2: allselect("schj.txt"); goto yyy;break; case 3: allselect("qthj.txt"); goto yyy;break; case 4: zdyselect(); case 5: break; case 6: exit(0); vo

20、id zdyselect(void) ssmmz: int n=0,j=0; char hh10; system("cls"); printf("n 歡迎使用戶籍管理系統(tǒng)n"); printf("n 自定義查詢信息nnn"); printf(" 請您輸入地址關(guān)鍵字:"); scanf("%s",hh); if(strcmp(hh,"0")!=0) struct hj *p; struct hj *q=NULL,*head=NULL; fp=fopen("hj.txt

21、","rb"); if(fp=NULL) printf("n 沒有記錄,請輸入記錄然后再查詢!"); getch(); goto jjz; while(!feof(fp) n+; p=(struct hj *)malloc(sizeof(struct hj); fread(p,sizeof(struct hj),1,fp); if(n=1) head=p; else q->next=p; q=p; q->next=NULL; p=head; while(p!=NULL) if(strstr(p->address,hh)!=NU

22、LL) int a; j+; printf("n 結(jié) 果 學(xué)號=%ld 姓名=%s 年齡=%d 性別=%s ",p->number,p->name,p->age,p->sex); printf("n 地址=%s",p->address); printf("nn 操 作 更改數(shù)據(jù) 刪除數(shù)據(jù) 查詢下一條數(shù)據(jù) 返回上頁 退出程序nn 請您選擇操作:");ssmz: scanf("%d",&a); switch(a) void hjedit(struct hj *headd,struc

23、t hj *pp); void hjdelete(struct hj *headdd,struct hj *ss); case 1: hjedit(head,p); goto ssmmz;break; case 2: hjdelete(head,p); goto ssmmz;break; case 3: p=p->next;continue; case 4: goto jjz; case 5:exit(0); default:printf("n 錯誤的選擇,請重新選擇:"); goto ssmz; p=p->next; else p=p->next; if

24、(j=0) printf("nnn沒有匹配的記錄 按任意鍵繼續(xù)!"); getch(); fclose(fp); goto ssmmz; else int xx; printf("nn查詢完畢! 繼續(xù)查詢 返回上一級菜單 退出程序"); printf("n請選擇:"); scanf("%d",&xx); if(xx=2) goto jjz; else if(xx=3) exit(0); goto ssmmz;jjz: ; void allselect(char a8)/全部查詢 int n=0; int k

25、=0; system("cls"); printf("n 歡迎使用戶籍管理系統(tǒng)n"); printf("n 籍貫方式信息nnn"); struct hj *p; struct hj *q=NULL,*head=NULL; fp=fopen(a,"rb"); if(fp=NULL) printf("n對不起,沒有記錄無法查詢!"); goto xxxx; rewind(fp); while(!feof(fp) n+; p=(struct hj *)malloc(sizeof(struct hj);

26、 fread(p,sizeof(struct hj),1,fp); if(n=1) head=p; else q->next=p; q=p; q->next=NULL; struct hj *h1,*p2,*q3,*r4,*s5; h1=p2=(hj *)malloc(sizeof(struct hj); p2->next=head; while(p2->next!=NULL) q3=p2->next; r4=p2; while(q3->next!=NULL) if(q3->next->number<p2->next->numb

27、er) 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學(xué)號=%ld 姓名=%s 年齡=%d 性別=%s ",p->number,p->name,p->age,p-&g

28、t;sex); printf("n地址=%s",p->address); p=p->next; xxxx: printf("n顯示完畢n 返回上級菜單 退出程序 n請 選 擇 :");xxx: scanf("%d",&n); switch(n) case 1:break; case 2:exit(0); default:printf("n錯誤的選擇,請重新選擇:"); goto xxx; void hjselect(void)/查詢編輯信息函數(shù) cxbegin: int a; system(&q

29、uot;cls"); printf("n 歡迎使用戶籍管理系統(tǒng)n"); printf("n 查詢編輯信息nnn"); printf("n 一 按學(xué)號方式查詢n"); printf("n 二 按姓名方式查詢n"); printf("n 三 按籍貫方式查詢n"); printf("n 四 顯示全部信息n"); printf("n 五 返回上級菜單n"); printf("n 請 選 擇 查 詢 方 式:");cxmm: scanf

30、("%d",&a); switch(a) case 1: hjxmselect();goto cxbegin;break; case 2: hjxhselect();goto cxbegin;break; case 3: hjjgselect();goto cxbegin;break; case 4: allselect("hj.txt");goto cxbegin;break; case 5: break; default:printf("n錯誤的選擇,請重新選擇:"); goto cxmm; void hjde(void)

31、/刪除界面函數(shù)cxxbegin: int a; system("cls"); printf("n 歡迎使用戶籍管理系統(tǒng)n"); printf("n 刪除信息nnn"); printf("n 一 按學(xué)號方式刪除n"); printf("n 二 按姓名方式刪除n"); printf("n 三 按籍貫方式刪除n"); printf("n 四 刪除全部信息n"); printf("n 五 返回上級菜單n"); printf("n 請

32、選 擇 刪 除 方 式:");cxxmm: scanf("%d",&a); int i=0; switch(a) case 1: hjxmselect();goto cxxbegin;break; case 2: hjxhselect();goto cxxbegin;break; case 3: zdyselect();goto cxxbegin;break; case 4: fp=fopen("hj.txt","wb"); if(fp!=NULL) i+; fp=fopen("schj.txt"

33、,"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(); goto cxxbegin;break; case 5: break; default:printf("n錯誤的選擇,請重新選擇:"); goto cxxmm; /=刪除函數(shù)接口=void hjdelete(struct hj *headdd,struct hj *ss

34、) struct hj *q; char d5="四川" if(headdd=ss) headdd=headdd->next; goto gogo; 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(struct hj),

35、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(struct hj),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(struct hj),1,fp); q=q->next; fclose(fp);/=編輯函數(shù)接口=void hjedit(struct hj *headd,struct hj *pp) int n=0; struct hj *p,*p1,*p2; char d5="四川" printf("n 輸 入 學(xué)號="); scanf("%ld",&pp->number); printf("

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論