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

下載本文檔

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

文檔簡介

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

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

3、 、學(xué)生學(xué)號(hào)、姓名、各門成績的錄入;b、鏈表數(shù)據(jù)顯示及清除;c 、鏈表數(shù)據(jù)的文件保存與讀?。凰?、實(shí)驗(yàn)結(jié)果及分析1、運(yùn)行結(jié)果請(qǐng)選棒換作二數(shù)據(jù)顯示數(shù)據(jù)顯示12 2 4 5宀木明江高紫 文 隸KKEKXlKJtJfXNKKJCKUJKK MX XXJ<JIJ<J<N M:嵐 JCKXHEXiKXXJIJlXKMlJC 學(xué)號(hào) 姓名 高數(shù)英語物理平均分909090.009&69.6035?0丁呂叼昭638767.00鉗耒顯示完畢,請(qǐng)按任意縫繼績2源程序主函數(shù)void mai n()int xz=0;struct xs *head;head=in it();while(xz!=5

4、)menu();scan f("%d",& xz);switch(xz)case 1:create(head); break;case 2:prin t(head); break;case 3:save(head); break;case 4:read(head);break;case 5:printf("n系統(tǒng)退出,拜拜!n");break;default:printf("n選擇錯(cuò)誤,請(qǐng)按任意鍵選擇!n");getch();break;fr(head); free(head);數(shù)據(jù)錄入源代碼void create(struc

5、t xs *hd)int xh,gs,yy,wl,i;char xm20;struct xs *p;fr(hd);printf("n請(qǐng)輸入學(xué)生個(gè)數(shù):");scan f("%d",&nu m);for(i=0;i <nu m;i+)printf("請(qǐng)輸入 %d 個(gè)學(xué)生 of %dn",i+1,num); prin tf("學(xué)號(hào):"); scan f("%d", &xh);printf("姓名:");scan f("%s",xm);pri

6、n tf("高數(shù):");scan f("%d",&gs);prin tf("英語:");scan f("%d", &yy);prin tf("物理:");scan f("%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->n ext=hd->n ext;h

7、d->n ext=p;prin tf("錄入數(shù)據(jù)完畢,請(qǐng)按任意鍵繼續(xù)!n");getch();添加記錄源代碼void prin t(struct xs *hd)struct xs*p;p=hd->n ext;if(p!=NULL)printf("n數(shù)據(jù)顯示 n");prin tf("*n")printf("學(xué)號(hào) 姓名 高數(shù) 英語物理平均分n");prin tf("*n")while(p!=NULL)printf("%4d ",p->xh);prin tf(&

8、quot;%10s",p->xm);prin tf("%8d",p->gs);prin tf("%7d",p->yy);prin tf("%6d",p->wl);prin tf("%8.2fn",(p->wl+p->wl+p->wl)/3.0);p=p->n ext;prin tf("*n")prin tf("鏈表顯示完畢,請(qǐng)按任意鍵繼續(xù)!n");getch();elseprintf("n當(dāng)前鏈表為空,請(qǐng)先讀

9、取文件或創(chuàng)建鏈表!n 按任意鍵繼續(xù)!n");查詢記錄源代碼void menu()system("cls");printf("*n");printf("*學(xué)生成績管理系統(tǒng)(1.0)*n");printf("*、n");printf("*jb11-1 31 宋潔 2012-7-3*n");printf("*n、);printf("*1-創(chuàng)建鏈表*n");printf("*2-數(shù)據(jù)顯示*n");printf("*3-保存文件*n&q

10、uot;);printf("*4-讀取文件*n");printf("*5-系統(tǒng)退出*n");printf("*n、);printf("請(qǐng)選擇操作(1-5:");源程序#in clude"stdio.h"#in clude"stdlib.h"#i ncludevstri ng.h>#in clude"con io.h"struct xsint xh;char xm20;in t gs,yy,wl;struct xs *n ext;;int num=0;struc

11、t xs *in it()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->n ext;while(hd-> next!=NULL)p=hd->n ext;hd->n ext=p->n ext;free(p);void create(struct xs *hd)int xh,gs,yy,wl,i;char xm20;struct xs *p;fr(hd);printf(

12、"n請(qǐng)輸入學(xué)生個(gè)數(shù):");scan f("%d",&nu m);for(i=0;i <nu m;i+)printf("請(qǐng)輸入 d 個(gè)學(xué)生 of %dn",i+1,num); prin tf("學(xué)號(hào):"); scan f("%d", &xh); printf("姓名:"); scan f("%s",xm); prin tf("高數(shù):"); scan f("%d",&gs); prin tf

13、("英語:"); scan f("%d", &yy); prin tf("物理:"); scan f("%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->n ext=hd->n ext;hd->n ext=p;prin tf("錄入數(shù)據(jù)完畢,請(qǐng)按任意鍵繼續(xù)!n");getc

14、h();void save(struct xs *hd)if(hd-> next!=NULL)struct xs *p=hd->n ext;int i;FILE *fp;fp=fope n( "yh.txt","w");fprin tf(fp,"%3dn", nu m);for(i=0;i <nu m;i+)fpri ntf(fp,"%3d %12s %3d %3d %3dn",p->xh,p->xm,p->gs,p->yy,p->wl); p=p->n ext

15、;fclose(fp);prin tf("n保存文件完畢,請(qǐng)按任意鍵繼續(xù)!n ");getch();elseprin tf("n當(dāng)前鏈表為空,不需要保存,請(qǐng)按任意鍵繼續(xù)!n");getch();void read(struct xs *hd)int i;struct xs *p;FILE *fp;fr(hd);fp=fope n("yh.txt","r");fscan f(fp,"%3dn",&nu m);for(i=0;i <nu m;i+)p=(struct xs *)mall

16、oc(sizeof(struct xs);fscan f(fp,"%3d %12s %3d %3d %3dn",p->xh,p->xm,p->gs,p->yy,p->wl); p->n ext=hd->n ext;hd->n ext=p;fclose(fp);prin tf("n讀取文件完畢,請(qǐng)按任意鍵繼續(xù)!n");getch();void prin t(struct xs *hd) struct xs*p; p=hd->n ext;if(p!=NULL)數(shù)據(jù)顯示n");prin tf(&q

17、uot;n prin tf("*n")printf("學(xué)號(hào) 姓名 高數(shù) 英語物理平均分n");prin tf("*n") while(p!=NULL) prin tf("%4d ",p->xh);prin tf("%10s",p->xm);prin tf("%8d",p->gs);prin tf("%7d",p->yy);prin tf("%6d",p->wl);prin tf("%8.2fn&q

18、uot;,(p->wl+p->wl+p->wl)/3.0);p=p->n ext;prin tf("*n") prin tf("鏈表顯示完畢,請(qǐng)按任意鍵繼續(xù)!n");getch(); else按任意鍵繼prin tf("n當(dāng)前鏈表為空,請(qǐng)先讀取文件或創(chuàng)建鏈表!n續(xù)!n");void menu()system("cls");printf("*n");printf("*學(xué)生成績管理系統(tǒng)(1.0)*n");printf("*、n");pr

19、intf("*jb11-1 31 宋潔 2012-7-3*n");printf("*、n");printf("*1-創(chuàng)建鏈表*n");printf("*2-數(shù)據(jù)顯示*n");printf("*3-保存文件*n");printf("*4-讀取文件*n");printf("*5-系統(tǒng)退出*n");printf("*n、);printf("請(qǐng)選擇操作(1-5:");void mai n()int xz=0;struct xs *he

20、ad; head=in it(); while(xz!=5) menu();scan f("%d", &xz); switch(xz) case 1:create(head); break;case 2:prin t(head); break;case 3: save(head); break;case 4:read(head); break;case 5:printf("n系統(tǒng)退出,拜拜!n");break;default:printf("n選擇錯(cuò)誤,請(qǐng)按任意鍵選擇!n");getch();break;fr(head); f

21、ree(head);3、試驗(yàn)收獲通過這次試驗(yàn),我掌握了鏈表的創(chuàng)建、遍歷顯示和清除功能,掌握了鏈表數(shù)據(jù)的文件保存、讀取,能夠熟練的使用VC+6.0,對(duì)C程序有了更深的了解。教 師 評(píng) 價(jià)評(píng)定項(xiàng)目ABCD評(píng)定項(xiàng)目ABCD算法正確界面美觀,布局合理程序結(jié)構(gòu)合理操作熟練語法、語義正確解析完整實(shí)驗(yàn)結(jié)果正確文字流暢報(bào)告規(guī)范題解正確其他:評(píng)價(jià)教師簽名:年 月曰代碼:#include"stdio.h"#include"stdlib.h"#include<string.h>#include"conio.h"struct xsint xh;c

22、har xm20;int 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 *hd)int xh,g

23、s,yy,wl,i;char xm20;struct xs *p;fr(hd);printf("n 請(qǐng)輸入學(xué)生個(gè)數(shù) :");scanf("%d",&num);for(i=0;i<num;i+)printf(" 請(qǐng)輸入 %d 個(gè)學(xué)生 of %dn",i+1,num);printf(" 學(xué)號(hào) :");scanf("%d",&xh);printf(" 姓名 :");scanf("%s",xm);printf(" 高數(shù) :"

24、;);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(&q

25、uot; 錄入數(shù)據(jù)完畢,請(qǐng)按任意鍵繼續(xù) !n ");getch();void save(struct xs *hd)if(hd->next!=NULL)struct xs *p=hd->next;int i;FILE *fp;fp=fopen("yh.txt","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

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

27、um;i+)p=(struct xs *)malloc(sizeof(struct xs);fscanf(fp,"%3d %12s %3d %3d %3dn",p->xh,p->xm,p->gs,p->yy,p->wl); p->next=hd->next;hd->next=p;fclose(fp);printf("n 讀取文件完畢,請(qǐng)按任意鍵繼續(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(" 學(xué)號(hào)姓名 高數(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->

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(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)論