C語言程序設計-基于鏈表的學生成績管理系統(tǒng)_第1頁
C語言程序設計-基于鏈表的學生成績管理系統(tǒng)_第2頁
C語言程序設計-基于鏈表的學生成績管理系統(tǒng)_第3頁
C語言程序設計-基于鏈表的學生成績管理系統(tǒng)_第4頁
C語言程序設計-基于鏈表的學生成績管理系統(tǒng)_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、華北科技學院計算機系綜合性實驗實驗報告課程名稱C語言程序設計實驗學期 2011 至2012 學年第二學期學生所在系部計算機系年級 2011專業(yè)班級計算機科學與技術(shù)B-111學生姓名 學號任課教師實驗成績計算機系制實驗報告須知1、 學生上交實驗報告時,必須為打印稿(A4 紙) 。頁面空間不夠,可以順延。2、 學生應該填寫的內(nèi)容包括:封面相關欄目實驗地點時間目的設備環(huán)境內(nèi)容結(jié)果及分析等。3、 教師應該填寫的內(nèi)容包括:實驗成績教師評價等。4、 教師根據(jù)本課程的綜合性實驗指導單中實驗內(nèi)容的要求,評定學生的綜合性實驗成績;要求在該課程期末考試前將實驗報告交給任課教師。綜合性實驗中,所涉及的程序,文檔等在

2、交實驗報告前,拷貝給任課教師。任課教師統(tǒng)一刻錄成光盤,與該課程的期末考試成績一同上交到系里存檔。5、 未盡事宜,請參考該課程的實驗大綱和教學大綱。C語言程序設計課程綜合性實驗報告開課實驗室:基礎五2012年7月6日實驗題目基于鏈表的學生成績管理系統(tǒng)一、實驗目的1、掌握鏈表的創(chuàng)建、遍歷顯示和消除;2、掌握鏈表數(shù)據(jù)的文件保存、讀??;二、設備與環(huán)境微型計算機、VC+三、實驗內(nèi)容1、定義結(jié)構(gòu)體,創(chuàng)建鏈表struct xsnodeint xh;char xm15;int gs;int yy;int wl;struct xsnode *next;2、根據(jù)以上鏈表結(jié)點結(jié)構(gòu),實現(xiàn)以下功能a、學生學號、姓名、各

3、門成績的錄入;b、鏈表數(shù)據(jù)顯示及清除;c、鏈表數(shù)據(jù)的文件保存與讀取;四、實驗結(jié)果及分析1、運行結(jié)果主菜單數(shù)據(jù)顯示2、源程序主函數(shù)void main()int xz=0;struct xs *head;head=init();while(xz!=5)menu();scanf("%d",&xz);switch(xz)case 1:create(head);break;case 2:print(head);break;case 3:save(head);break;case 4:read(head);break;case 5:printf("n系統(tǒng)退出,拜拜!n

4、");break;default:printf("n選擇錯誤,請按任意鍵選擇!n ");getch();break;fr(head);free(head);數(shù)據(jù)錄入源代碼void create(struct xs *hd)i nt xh,gs,yy,wl,i;char xm20;struct xs *p;f r(hd);printf("n請輸入學生個數(shù):");scanf("%d”,&num);f or(i=0;i<num;i+)printf(" 請輸入 d 學生 of %dn",i+1,num);pr

5、intf(" 學號:");scanf("%d",&xh);printf("姓名:");scanf("%s",xm);printf("高數(shù):");scanf("%d",&gs);printf("英語:");scanf("%d",&yy);printf("物理:");scanf("%d",&wl);p=(struct xs *)malloc(sizeof(struct

6、xs);p->xh=xh; strcpy(p->xm,xm); p->gs=gs;p->yy=yy; p->wl=wl; p->next=hd->next; hd->next=p;錄入數(shù)據(jù)完畢,請按任意鍵繼續(xù)!n "); printf(" getch(); 添加記錄源代碼void print(struct xs *hd) struct xs*p;p=hd->next;if(p!=NULL)數(shù)據(jù)顯示n");printf("nprintf("*n");printf(" 學號姓

7、名英語物理平均分n");printf("*n"); while(p!=NULL)printf("%4d ",p->xh);printf("%10s",p->xm);printf("%8d",p->gs);printf("%7d",p->yy);printf("%6d",p->wl);printf("%n",(p->wl+p->wl+p->wl)/;p=p->next;printf("

8、*n");printf("getch();elseprintf("n續(xù)!n ");查詢記錄源代碼 void menu() system("cls");鏈表顯示完畢,t#按任意鍵繼續(xù)!n");當前鏈表為空,請先讀取文件或創(chuàng)建鏈表!n按任意鍵繼printf(" printf(" printf("*學生成績管理系統(tǒng)*n");*n");*n");printf(" *jb11-1 31宋潔 2012-7-3*n");printf(" *n&quo

9、t;);printf(" *1-創(chuàng)建鏈表*n");printf(" *2-數(shù)據(jù)顯示*n");printf(" *3-保存文件*n");printf(" *4-讀取文件*n");printf(" *5-系統(tǒng)退出*n");printf(" *n");printf("請選擇操作(1-5:");源程序#include""#include""#include<>#include""struct

10、xsi nt xh;char xm20;i nt gs,yy,wl;struct xs *next;;int num=0;struct xs *init()struct xs* hd;hd=(struct xs *)malloc(sizeof(struct xs);hd->next=NULL;return hd;void fr(struct xs *hd)struct xs *p;p=hd->next;while(hd->next!=NULL) p=hd->next;hd->next=p->next;free(p);void create(struct xs

11、 *hd)i nt xh,gs,yy,wl,i;char xm20;struct xs *p;f r(hd);printf("n請輸入學生個數(shù):");scanf("%d”,&num);f or(i=0;i<num;i+)printf(" 請輸入 d 學生 of %dn",i+1,num);printf(" 學號:");scanf("%d",&xh);printf("姓名:");scanf("%s",xm);printf("高數(shù):&qu

12、ot;);scanf("%d",&gs);printf("英語:");scanf("%d",&yy);printf("物理:");scanf("%d",&wl);p=(struct xs *)malloc(sizeof(struct xs);p->xh=xh;strcpy(p->xm,xm);p->gs=gs;p->yy=yy;p->wl=wl;p->next=hd->next;hd->next=p;printf("

13、;錄入數(shù)據(jù)完畢,請按任意鍵繼續(xù)!n ");getch();void save(struct xs *hd)if(hd->next!=NULL)struct xs *p=hd->next;int i;FILE *fp;fp=fopen("","w");fprintf(fp,"%3dn",num);for(i=0;i<num;i+) f printf(fp,"%3d %12s %3d %3d %3dn",p->xh,p->xm,p->gs,p->yy,p->wl

14、); p=p->next;fclose(fp);printf("n保存文件完畢,請按任意鍵繼續(xù)!n ");getch();_elseprintf("n getch();void read(struct xs *hd)當前鏈表為空,不需要保存,請按任意鍵繼續(xù)!n ");int i;struct xs *p;FILE *fp;fr(hd);fp=fopen("","r");fscanf(fp,"%3dn",&num);for(i=0;i<num;i+)p=(struct xs *

15、)malloc(sizeof(struct xs);fscanf(fp,"%3d %12s %3d %3d %3dn"p>xh,p->xm,p->gsp>yyp>wl);p->next=hd->next;hd->next=p;fclose(fp);printf("n getch();void print(struct xs *hd)struct xs*p;p=hd->next;if(p!=NULL)printf("n讀取文件完畢,請按任意鍵繼續(xù)!n ");數(shù)據(jù)顯示n");print

16、f("*n");printf(" 學號姓名英語物理平均分n");printf("*n"); while(p!=NULL)printf("%4d ",p->xh);printf("%10s",p->xm);printf("%8d",p->gs);printf("%7d",p->yy);printf("%6d",p->wl);printf("%n",(p->wl+p->wl+p-

17、>wl)/;p=p->next;printf("*n");printf("鏈表顯示完畢,請按任意鍵繼續(xù)!n");getch();elseprintf("n當前鏈表為空,請先讀取文件或創(chuàng)建鏈表!n按任意鍵繼續(xù)!n ");void menu()system("cls");printf("*n");printf("*學生成績管理系統(tǒng)*n");printf("*肝);printf("*jb11-1 31宋潔 2012-7-3*n");prin

18、tf("*5);printf("*1-創(chuàng)建鏈表*n");printf("*2-數(shù)據(jù)顯示*n");printf("*3-保存文件*n");printf("*4-讀取文件*n");printf("*5-系統(tǒng)退出*n");printf("*n");printf("請選擇操作(1-5:");void main()i nt xz=0;struct xs *head;head=init();while(xz!=5)menu();scanf("%d&

19、quot;,&xz); switch(xz) case 1:create(head); break;case 2: print(head); break;case 3: save(head); break;case 4: read(head); break;case 5:printf("n系統(tǒng)退出,拜拜!n");break;default:printf("n選擇錯誤,請按任意鍵選擇!n ");getch(); break;fr(head);free(head);3、試驗收獲通過這次試驗,我掌握了鏈表的創(chuàng)建、遍歷顯示和清除功能,掌握了鏈表數(shù)據(jù)的文件

20、保存、讀取,能夠熟練的使用VC+對C程序有了更深的了解教 師 評 價評定項目ABCD評定項目ABCD算法正確界囿美觀,布局合理程序結(jié)構(gòu)合理操作熟練語法、語義正確解析完整實驗結(jié)果正確義字流暢報告規(guī)范題解正確其他:評價教師簽名:年 月日代碼:#include""#include""#include<>#include""struct xsint xh;char xm20;int gs,yy,wl;struct xs *next;int num=0;struct xs *init()struct xs* hd;hd=(struc

21、t xs *)malloc(sizeof(struct xs);hd->next=NULL;return hd;void fr(struct xs *hd)struct xs *p;p=hd->next;while(hd->next!=NULL)p=hd->next;hd->next=p->next;free(p);void create(struct xs *hd)int xh,gs,yy,wl,i;char xm20;struct xs *p;fr(hd);printf("n 請輸入學生個數(shù):");scanf("%d&quo

22、t;,&num);for(i=0;i<num;i+)printf("請輸入 d個學生 of %dn",i+1,num);printf(" 學號 :");scanf("%d",&xh);printf("姓名:");scanf("%s",xm);printf("高數(shù):");scanf("%d",&gs);printf("英語:");scanf("%d",&yy);printf(&qu

23、ot;物理:");scanf("%d",&wl);p=(struct xs *)malloc(sizeof(struct xs);p->xh=xh;strcpy(p->xm,xm);p->gs=gs;p->yy=yy;p->wl=wl;p->next=hd->next;hd->next=p;printf("錄入數(shù)據(jù)完畢,請按任意鍵繼續(xù)!n ");getch();void save(struct xs *hd)if(hd->next!=NULL)struct xs *p=hd->

24、next;int i;FILE *fp;fp=fopen("","w");fprintf(fp,"%3dn",num);for(i=0;i<num;i+)fprintf(fp,"%3d %12s %3d %3d %3dn",p->xh,p->xm,p->gs,p->yy,p->wl);p=p->next;fclose(fp);printf("n 保存文件完畢,請按任意鍵繼續(xù)!n ");getch();elseprintf("n 當前鏈表為空,不

25、需要保存,請按任意鍵繼續(xù)!n ");getch();void read(struct xs *hd)int i;struct xs *p;FILE *fp;fr(hd);fp=fopen("","r");fscanf(fp,"%3dn",&num);for(i=0;i<num;i+)p=(struct xs *)malloc(sizeof(struct xs);fscanf(fp,"%3d %12s %3d %3d %3dn",p->xh,p->xm,p->gs,p->

26、;yy,p->wl);p->next=hd->next;hd->next=p;fclose(fp);printf("n讀取文件完畢,請按任意鍵繼續(xù)!n ");getch();void print(struct xs *hd)struct xs*p;p=hd->next;if(p!=NULL)printf("n數(shù)據(jù)顯示n");printf("*n");printf(" 學號姓名高數(shù) 英語 物理 平均分 n");printf("*n");while(p!=NULL)printf("%4d ",p->xh);printf("%10s",p->xm);printf("%8d",p->gs);printf("%7d",p->yy);printf("%6d",p->wl);printf("%

溫馨提示

  • 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論