




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、華北科技學(xué)院計算機系綜合性實驗實 驗 報 告 課程名稱 C語言程序設(shè)計 實驗學(xué)期 2011 至 2012 學(xué)年 第 二 學(xué)期 學(xué)生所在系部 計算機系 年級 2011 專業(yè)班級 計算機科學(xué)與技術(shù)B-111 學(xué)生姓名 學(xué)號 任課教師 實驗成績 計算機系制實驗報告須知1、 學(xué)生上交實驗報告時,必須為打印稿(A4紙)。頁面空間不夠,可以順延。2、 學(xué)生應(yīng)該填寫的內(nèi)容包括:封面相關(guān)欄目、實驗地點、時間、目的、設(shè)備環(huán)境、內(nèi)容、結(jié)果及分析等。3、 教師應(yīng)該填寫的內(nèi)容包括:實驗成績、教師評價等。4、 教師根據(jù)本課程的綜合性實驗指導(dǎo)單中實驗內(nèi)容的要求,評定學(xué)生的綜合性實驗成績;要求在該課程期末考試前將實驗報告交
2、給任課教師。綜合性實驗中,所涉及的程序,文檔等在交實驗報告前,拷貝給任課教師。任課教師統(tǒng)一刻錄成光盤,與該課程的期末考試成績一同上交到系里存檔。5、 未盡事宜,請參考該課程的實驗大綱和教學(xué)大綱。C語言程序設(shè)計課程綜合性實驗報告開課實驗室:基礎(chǔ)五 2012年7月 6 日實驗題目基于鏈表的學(xué)生成績管理系統(tǒng)一、實驗?zāi)康?、掌握鏈表的創(chuàng)建、遍歷顯示和清除; 2、掌握鏈表數(shù)據(jù)的文件保存、讀??;二、設(shè)備與環(huán)境 微型計算機、VC+6.0三、實驗內(nèi)容1、定義結(jié)構(gòu)體,創(chuàng)建鏈表struct xsnode int xh; char xm15; int gs; int yy; int wl; struct xsnod
3、e *next;2、根據(jù)以上鏈表結(jié)點結(jié)構(gòu),實現(xiàn)以下功能 a、學(xué)生學(xué)號、姓名、各門成績的錄入; 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); brea
4、k; case 4: read(head); break; case 5: printf("n 系統(tǒng)退出,拜拜!n "); break;default:printf("n 選擇錯誤,請按任意鍵選擇!n ");getch();break; fr(head); free(head); 數(shù)據(jù)錄入源代碼void create(struct xs *hd)int xh,gs,yy,wl,i;char xm20;struct xs *p;fr(hd);printf("n 請輸入學(xué)生個數(shù):");scanf("%d",&n
5、um);for(i=0;i<num;i+)printf("請輸入%d個學(xué)生 of %dn",i+1,num);printf(" 學(xué)號:");scanf("%d",&xh);printf(" 姓名:");scanf("%s",xm);printf(" 高數(shù):");scanf("%d",&gs);printf(" 英語:");scanf("%d",&yy);printf(" 物理:
6、");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 print(struct xs *hd) struct xs*p;p=hd->next;if(p!=NULL
7、)printf("n 數(shù)據(jù)顯示n");printf("*n");printf(" 學(xué)號 姓名 高數(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);pri
8、ntf("%8.2fn",(p->wl+p->wl+p->wl)/3.0);p=p->next;printf("*n");printf(" 鏈表顯示完畢,請按任意鍵繼續(xù)!n"); getch();elseprintf("n 當前鏈表為空,請先讀取文件或創(chuàng)建鏈表!n 按任意鍵繼續(xù)!n "); 查詢記錄源代碼void menu()system("cls");printf(" *n");printf(" * 學(xué)生成績管理系統(tǒng)(1.0) *n&quo
9、t;);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");printf(" * 4-讀取文件 *n");printf(" * 5-系統(tǒng)退出 *n");printf(" *n");printf(&quo
10、t; 請選擇操作(1-5:"); 源程序#include"stdio.h"#include"stdlib.h"#include<string.h>#include"conio.h"struct xsint xh;char 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
11、 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 請輸入學(xué)生個數(shù):");scanf("%d",&num);for(i=0;i<num;i+)printf("請輸入%d個學(xué)生 of %dn
12、",i+1,num);printf(" 學(xué)號:");scanf("%d",&xh);printf(" 姓名:");scanf("%s",xm);printf(" 高數(shù):");scanf("%d",&gs);printf(" 英語:");scanf("%d",&yy);printf(" 物理:");scanf("%d",&wl);p=(struct xs *
13、)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->next;int i;FILE *fp;fp=fopen("yh.txt","w&q
14、uot;);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 當前鏈表為空,不需要保存,請按任意鍵繼續(xù)!n ");getch();void read(struct xs
15、*hd)int i;struct xs *p;FILE *fp;fr(hd);fp=fopen("yh.txt","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->yy,p->wl); p->next=hd->next; hd-&
16、gt;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(" 學(xué)號 姓名 高數(shù) 英語 物理 平均分n");printf("*n");while(p!=NULL)printf("%4d ",p->xh);print
17、f("%10s",p->xm);printf("%8d",p->gs);printf("%7d",p->yy);printf("%6d",p->wl);printf("%8.2fn",(p->wl+p->wl+p->wl)/3.0);p=p->next;printf("*n");printf(" 鏈表顯示完畢,請按任意鍵繼續(xù)!n"); getch();elseprintf("n 當前鏈表為空,請先讀
18、取文件或創(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(&quo
19、t; * 3-保存文件 *n");printf(" * 4-讀取文件 *n");printf(" * 5-系統(tǒng)退出 *n");printf(" *n");printf(" 請選擇操作(1-5:"); 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
20、(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ù)的文件保存、讀取,能夠熟練的使用VC+6.0,對C程序有了更深的了解。教 師 評 價評定項目ABCD評定項目ABCD算法正確
21、界面美觀,布局合理程序結(jié)構(gòu)合理操作熟練語法、語義正確解析完整實驗結(jié)果正確文字流暢報告規(guī)范題解正確其他:評價教師簽名:年 月 日代碼:#include"stdio.h"#include"stdlib.h"#include<string.h>#include"conio.h"struct xsint xh;char xm20;int gs,yy,wl;struct xs *next;int num=0;struct xs *init() struct xs* hd;hd=(struct xs *)malloc(sizeof(s
22、truct 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 請輸入學(xué)生個數(shù):");scanf("%d",&num);for(i=0
23、;i<num;i+)printf("請輸入%d個學(xué)生 of %dn",i+1,num);printf(" 學(xué)號:");scanf("%d",&xh);printf(" 姓名:");scanf("%s",xm);printf(" 高數(shù):");scanf("%d",&gs);printf(" 英語:");scanf("%d",&yy);printf(" 物理:");sca
24、nf("%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->next;int i;FILE
25、*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,p->wl);p=p->next;fclose(fp);printf("n 保存文件完畢,請按任意鍵繼續(xù)!n ");getch();elseprintf("n 當前鏈表為空,不需要保存,請按任意鍵
26、繼續(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<num;i+) p=(struct xs *)malloc(sizeof(struct xs); fscanf(fp,"%3d %12s %3d %3d %3dn",p->xh,p->xm,p->gs,p->y
27、y,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(" 學(xué)號 姓名 高數(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("%8.2fn",(p->wl+p->wl+p-
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 兒童教育合同范本
- 修鄉(xiāng)村路橋合同范本
- 偽造備案租房合同范本
- 創(chuàng)業(yè)五人合作合同范本
- 加盟 商鋪轉(zhuǎn)讓合同范本
- 全國租賃服裝合同范本
- 買賣店鋪裝修合同范本
- 劃經(jīng)營合同范本
- 2025內(nèi)蒙古新工創(chuàng)業(yè)發(fā)展集團有限責(zé)任公司公開招聘工作人員筆試參考題庫附帶答案詳解
- epc項目建設(shè)合同范本
- 輪狀病毒性腸炎
- 世界社會主義五百年
- 加氫裂化操作工題庫(合并版)
- 正大集團大豬場開發(fā)流程
- 高中政治必修四知識體系每單元的總體框架
- 房地產(chǎn)金融創(chuàng)新與風(fēng)險防范的理論演進
- GB/T 41255-2022智能工廠通用技術(shù)要求
- GB/T 41029-2021石油天然氣鉆井海洋棄井作業(yè)規(guī)程
- 深入推進依法行政
- GB/T 4026-1992電器設(shè)備接線端子和特定導(dǎo)線線端的識別及應(yīng)用字母數(shù)字系統(tǒng)的通則
- 馬工程教材《公共財政概論》PPT-第二章 公共財政職能
評論
0/150
提交評論