學(xué)生信息管理系統(tǒng)_第1頁(yè)
學(xué)生信息管理系統(tǒng)_第2頁(yè)
學(xué)生信息管理系統(tǒng)_第3頁(yè)
已閱讀5頁(yè),還剩8頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、實(shí)用文檔#include#include#include#include#include#define LEN sizeof(struct student)#define DAT_FILENAME Information.txt/*定義數(shù)據(jù)結(jié)構(gòu) */struct dateint year;int month;int day;struct studentint ID;char Name8;int age;char xb;char telephone15;char address40;struct date birthday;char email40;struct student *next;/*

2、函數(shù)原型*/void DispMainMenu();void DisplayInformation(struct student *head);struct student *FindstudentID(struct student *head,int findID);struct student *FindstudentName(struct student *head,char findname); struct student *InformationInput(struct student *head); void QueryInformation(struct student *he

3、ad);struct student *EditInformation(struct student *head);struct student *Insert(struct student *head,struct student *p);void Save(struct student *head);struct student *Read(struct student *head);struct student *Delete(struct student *head,int findID);實(shí)用文檔struct student *Add(struct student *head);vo

4、id Help();/*顯示主菜單 */void DispMainMenu()printf(*n);printf(n);printf(tttt1-信息錄入 n);printf(n);printf(tttt2-信息修改 n);printf(n);printf(tttt3-信息查詢 n);printf(n);printf(tttt4-保存數(shù)據(jù)到文件n);printf(n);printf(tttt5-打開(kāi)數(shù)據(jù)文件 n);printf(n);printf(tttt6-文件追加 n);printf(n);printf(tttt7-幫助 n);printf(n);printf(tttt0-退出 n);pr

5、intf(n);學(xué)生信息管理系統(tǒng)printf(友情提示:初次使用請(qǐng)先閱讀幫助n);printf(* *n);printf(請(qǐng)選擇 (0-7):);/*顯示主菜單 */*幫助*/void Help()printf(ntttprintf(t1.printf(t2.printf(t3.歡迎進(jìn)入幫助系統(tǒng)!nn);請(qǐng)按照主菜單提示選擇所需執(zhí)行功能的數(shù)字代號(hào)!n);所有文件請(qǐng)按照規(guī)范輸入n);剛開(kāi)始執(zhí)行程序時(shí)若需要文本文件里的數(shù)據(jù),請(qǐng)先進(jìn)行讀取文件信息!n);printf(t4.修改信息以后,請(qǐng)切記需要保存!n);實(shí)用文檔printf(n);/*顯示所有學(xué)生信息*/void DisplayInformat

6、ion(struct student *head)struct student *p;printf(*);printf(n學(xué)號(hào) t姓名 t年齡 t性別 t電話 tt地址 t出生年月t emailn);p=(struct student *)malloc(LEN);p=head;if(head!=NULL)while(p!=NULL)printf(%-dt%-st%-dt,p-ID,p-Name,p-age);printf(%-ct%-st%-st,p-xb,p-telephone,p-address);printf(%-d %d %d,p-birthday.year,p-birthday.mo

7、nth,p-birthday.day); printf(t%-sn,p-email);p=p-next;elseprintf(無(wú)數(shù)據(jù) n);/*查找指定學(xué)號(hào)的學(xué)生信息*/struct student *FindstudentID(struct student *head,int findID)struct student *p;p=(struct student *)malloc(LEN);p=head;if(head!=NULL)while(p!=NULL)if(p-ID=findID)break;p=p-next;實(shí)用文檔elseprintf(無(wú)數(shù)據(jù) n);return p;/*查找指定姓

8、名的學(xué)生信息*/struct student *FindstudentName(struct student *head,char findname)struct student *p;p=(struct student *)malloc(LEN);p=head;if(head!=NULL)while(p!=NULL)if(strcmp(p-Name,findname)=0)break;p=p-next;elseprintf(無(wú)數(shù)據(jù) n);return p;/*學(xué)生信息錄入 */struct student *InformationInput(struct student *head)int

9、number,i;struct student *p;p=(struct student *)malloc(LEN);printf(n請(qǐng)輸入本次錄入的學(xué)生人數(shù):);scanf(%d,&number);for(i=0;iID);實(shí)用文檔printf(ttt姓名: t);scanf(%s,p-Name);printf(ttt年齡: t);scanf(%d,&p-age);printf(ttt性別 ( 男 M、女 W): );scanf(%s,&p-xb);printf(ttt電話 ( 八位 ) : t);scanf(%s,p-telephone);printf(ttt地址: t);scanf(%s

10、,p-address);printf(ttt出生年月: t);scanf(%d%d%d,&p-birthday.year,&p-birthday.month,&p-birthday.day); printf(tttemail:t);scanf(%s,p-email);head=Insert(head,p);p=(struct student *)malloc(LEN);printf(n您的輸入信息是:n);DisplayInformation(head);return(head);/*學(xué)生信息查詢*/void QueryInformation(struct student *head)char

11、 select;int findID;char findname8;struct student *p;printf(*printf(t1-按學(xué)號(hào)查詢;t2-請(qǐng)選擇查詢方式*n);按姓名查詢 n);printf(*n);printf(請(qǐng)選擇(1-2):);/*顯示菜單信息*/select=getche();getch();switch (select)case1:printf(n按學(xué)號(hào)查詢n請(qǐng)輸入學(xué)生的學(xué)號(hào):);scanf(%d,&findID);if(p=FindstudentID(head,findID)!=NULL) /*找到指定學(xué)號(hào)的學(xué)生*/實(shí)用文檔printf(nprintf(n查找

12、結(jié)果如下:學(xué)號(hào) t姓名 tn);年齡 t性別 t電話 tt地址 t出生年月temailn);printf(%dt%st%dt,p-ID,p-Name,p-age);printf(%ct%st%st,p-xb,p-telephone,p-address);printf(%d %d %d,p-birthday.year,p-birthday.month,p-birthday.day); printf(t%sn,p-email);else/*沒(méi)有找到 */printf(您輸入的學(xué)號(hào)不存在!n);break;case2:printf(n按姓名查詢 n請(qǐng)輸入學(xué)生的姓名:scanf(%s,&findnam

13、e);if(p=FindstudentName(head,findname)!=NULL) /*);找到指定姓名的學(xué)生*/printf(nprintf(n查找結(jié)果如下:學(xué)號(hào) t姓名 tn);年齡 t性別 t電話 t地址 t出生年月t emailn);printf(%dt%st%dt,p-ID,p-Name,p-age);printf(%ct%st%st,p-xb,p-telephone,p-address);printf(%d %d %d,p-birthday.year,p-birthday.month,p-birthday.day); printf(t%sn,p-email);else/*沒(méi)

14、有找到 */printf(您輸入的姓名不存在!n);break;default:printf(選擇錯(cuò)誤! n);/*修改學(xué)生信息*/struct student *EditInformation(struct student *head)int findID;char select;實(shí)用文檔struct student *p;printf(n請(qǐng)輸入學(xué)生的學(xué)號(hào):);scanf(%d,&findID);if(p=FindstudentID(head,findID)!=NULL)/*找到指定學(xué)號(hào)的學(xué)生*/printf(*printf(t1-修改信息;t2-請(qǐng)修改方式 *n);刪除信息 n);prin

15、tf(*n);printf(請(qǐng)選擇 (1-2):);select=getche();getch();switch (select)case1:/*修改信息 */printf(您選擇的是修改信息!n);printf(姓名: %sn,p-Name);printf(原信息:學(xué)號(hào)別: %cn,p-ID,p-age,p-xb);printf(t電話址: %stemail:%sn,p-telephone,p-address,p-email);printf(請(qǐng)輸入新信息 n);:%dt:年齡:%st%dt性地printf(學(xué)號(hào) t);scanf(%d,&p-ID);printf(姓名: t);scanf(%

16、s,p-Name);printf(年齡: t);scanf(%d,&p-age);printf(性別 ( 男 M、女 W):);scanf(%s,&p-xb);printf(電話: t);scanf(%s,p-telephone);printf(地址: t);scanf(%s,p-address);printf(出生年月: t);scanf(%d%d%d,&p-birthday.year,&p-birthday.month,&p-birthday.day); printf(email:t);scanf(%s,p-email);break;case2:/*刪除信息 */printf(您選擇的是刪

17、除信息!n);head=Delete(head,findID);實(shí)用文檔break;else/*沒(méi)有找到學(xué)號(hào)匹配的記錄*/printf(您輸入的學(xué)號(hào)不存在!n);return (head);/*有序插入 */struct student *Insert(struct student *head,struct student *p)struct student *p0,*p1;if(head=NULL)head=p;p-next=NULL;return(head);if(p-IDID)p-next=head;head=p;return(head);p1=head;while(p-IDp1-ID)

18、&(p1-next!=NULL)p0=p1;p1=p1-next;if(p-IDID)p-next=p1;p0-next=p;elseif(p-ID=p1-ID);else實(shí)用文檔p1-next=p;p-next=NULL;return(head);/*保存數(shù)據(jù)到文件*/void Save(struct student *head)FILE *fp;struct student *p;p=head;if(fp=fopen(DAT_FILENAME,w+)!=NULL)/*以 W+的方式打開(kāi)文件*/while(p!=NULL)fprintf(fp,%dt,p-ID);fprintf(fp,%st

19、,p-Name);fprintf(fp,%dt,p-age);fprintf(fp,%ct,p-xb);fprintf(fp,%st,p-telephone);fprintf(fp,%st,p-address);fprintf(fp,%d%d%dt,p-birthday.year,p-birthday.month,p-birthday.day);fprintf(fp,%sn,p-email);p=p-next;/*將鏈表的內(nèi)容寫(xiě)入文件*/fclose(fp);實(shí)用文檔elseprintf(cannot open filen);/*打開(kāi)數(shù)據(jù)文件*/struct student *Read(str

20、uct student *head)struct student *p;p=(struct student *)malloc(LEN);FILE *fp;if(fp=fopen(DAT_FILENAME,r)!=NULL)/* 讀取文件中的內(nèi)容到鏈表中*/while(fscanf(fp,%dt,&p-ID)!=EOF)fscanf(fp,%st,p-Name);fscanf(fp,%dt,&p-age);fscanf(fp,%ct,&p-xb);fscanf(fp,%st,p-telephone);fscanf(fp,%st,p-address);fscanf(fp,%d %d %dt,&p-

21、birthday.year,&p-birthday.month,&p-birthday.day);fscanf(fp,%sn,p-email);head=Insert(head,p);p=(struct student *)malloc(LEN);fclose(fp);elseprintf(cannot open filen);return head;實(shí)用文檔/*文件內(nèi)容追加*/struct student *Add(struct student *head)head=Read(head);head=InformationInput(head);return (head);/*刪除信息 */s

22、truct student *Delete(struct student *head,int findID)struct student *pre,*p;if(head-ID=findID)p=head;head=head-next;elsepre=head;p=pre-next;while(p!=NULL&p-ID!=findID)pre=p;p=p-next;if(p-ID=findID)pre-next=p-next;free(p);return (head);/*主函數(shù) */void main()實(shí)用文檔char select,c;struct student *head;head=NULL;select=0;while(select!=0)DispMainMenu();select=getche();getch();switch(select)case0:printf(n您選擇的是退出!n);_beep(300,

溫馨提示

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

評(píng)論

0/150

提交評(píng)論