




已閱讀5頁,還剩15頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
成績評定教師簽名嘉應(yīng)學(xué)院 計算機(jī)學(xué)院實(shí)驗報告課程名稱: C+程序設(shè)計課程設(shè)計 開課學(xué)期: 20102011學(xué)年第2學(xué)期 班 級: 計算機(jī)091班 指導(dǎo)老師: 馮斯苑 項目題目: 學(xué)生成績管理系統(tǒng) 學(xué)生姓名(學(xué)號):第 4 組: 羅維權(quán)(2091111137) 吳煒東(2091111114) 劉威林(2091111133) 提交時間: 一、實(shí)驗?zāi)康?、進(jìn)一步鞏固所學(xué)程序設(shè)計語言(主要是C、C+)的基本概念和理論;2、熟練掌握結(jié)構(gòu)化程序設(shè)計和面向?qū)ο蟪绦蛟O(shè)計的方法和理念;2、培養(yǎng)實(shí)際分析問題、實(shí)踐動手編程的能力;3、培養(yǎng)團(tuán)隊協(xié)作精神。二、實(shí)驗內(nèi)容本系統(tǒng)是一個學(xué)生成績管理系統(tǒng),采用VC+6.0 編譯器作為開發(fā)環(huán)境,這個環(huán)境是我們在學(xué)習(xí)C+的平臺。輸入數(shù)據(jù)類型主要是char、int、float等數(shù)據(jù)類型,輸入內(nèi)容包括:班級、學(xué)號、姓名、數(shù)據(jù)結(jié)構(gòu)、C+ 程序設(shè)計、大學(xué)語文、大學(xué)英語、概率統(tǒng)計、大學(xué)體育、毛澤東思想等數(shù)據(jù)。用戶在輸入學(xué)生數(shù)據(jù)時要保證輸入數(shù)據(jù)格式的正確性,系統(tǒng)不會自動檢測輸入的數(shù)據(jù)是否正確,可用。輸出形式與輸入形式類似,根據(jù)需要可以選擇顯示輸入的各項內(nèi)容,還可以選擇顯示計算好平均分后并排序后的記錄,顯示內(nèi)容包括:班級、學(xué)號、姓名、平均分等數(shù)據(jù)。用戶運(yùn)行程序后進(jìn)入系統(tǒng)主界面,在主界面用戶可以輸入所有學(xué)生的數(shù)據(jù)并保存到文件中,也可以讀取文件中已有的學(xué)生數(shù)據(jù)。用戶在保存數(shù)據(jù)的時候,如果保存位置沒有文件則自動新建一個文件進(jìn)行保存。本系統(tǒng)同時只能對一個數(shù)據(jù)文件進(jìn)行相關(guān)操作,不能同時打開多個數(shù)據(jù)文件,其類似于單用戶操作系統(tǒng)。當(dāng)用戶讀取學(xué)生數(shù)據(jù)后可對其進(jìn)行顯示,插入,刪除,修改,排序,計算平均分等相關(guān)操作。用戶在操作過程中可隨時對當(dāng)前文件進(jìn)行保存到文件操作,以防止修改的數(shù)據(jù)丟失。三、算法描述1)主函數(shù)main():定義學(xué)生結(jié)構(gòu)體數(shù)組,調(diào)用錄入、統(tǒng)計等函數(shù)對成績表進(jìn)行處理;2)錄入函數(shù)Input():輸入班級到政治課成績;3)統(tǒng)計函數(shù)Statistic():計算平均成績;4)查詢函數(shù)Lookup():查詢指定學(xué)號學(xué)生成績記錄;5)修改函數(shù)Modify():修改指定學(xué)號學(xué)生成績記錄;6)刪除函數(shù)Delete():刪除指定學(xué)號學(xué)生記錄;7)輸出函數(shù)Output():輸出班級所有學(xué)生成績記錄;8) 排序函數(shù)Sort():按平均分對學(xué)生成績記錄項進(jìn)行降序排序;9)插入函數(shù)Insert():按平均分順序插入新記錄。四、程序結(jié)構(gòu)main用戶驗證1菜單 1輸入學(xué)生成績2顯示統(tǒng)計數(shù)據(jù)3查找學(xué)生成績4修改學(xué)生成績5刪除學(xué)生成績6插入學(xué)生成績7按平均分降序排列8顯示全部學(xué)生成績0退出本系統(tǒng)本系統(tǒng)1輸入學(xué)生成績2顯示統(tǒng)計數(shù)據(jù)6插入學(xué)生成績7按平均分降序排列5刪除學(xué)生成績8顯示全部學(xué)生成績3查找學(xué)生成績4修改學(xué)生成績菜單代碼0退出本系統(tǒng)圖2 程序總體框架五、程序技巧或創(chuàng)新在main()函數(shù)中主要是通過”switch(menu()”選擇判斷來調(diào)用相關(guān)功能模塊。系統(tǒng)的運(yùn)行是在一個永真的循環(huán)里進(jìn)行的,只有在主界面并選擇“退出本系統(tǒng)”時,才會跳出永真循環(huán),并退出程序。主函數(shù)代碼為:void main() /*主函數(shù)*/ for(;) switch(menu() /*選擇判斷*/ case 1: Input(stud);/*輸入學(xué)生成績*/ break; case 2: Statistic(stud); /*輸出學(xué)生統(tǒng)計數(shù)據(jù)*/ break; case 3: Lookup(stud); /*查找學(xué)生成績*/ coutttt; system(pause); break; case 4: Modify(stud); /*修改學(xué)生成績*/ coutttt; system(pause); break; case 5: Delete(stud); /*按學(xué)號查找,刪除學(xué)生信息*/ coutttt; system(pause); break; case 6: Insert(stud);/*增加學(xué)生成績*/ coutttt; system(pause); break; case 7: Sort(stud); /*按平均分對學(xué)生成績記錄項進(jìn)行降序排序*/ coutttt; system(pause); break; case 8: Output(stud); /*顯示全部學(xué)生成績*/ coutttt; system(pause); break; case 0: coutendl =nendl; /*結(jié)束程序*/ coutttt; system(pause); exit(0); 主界面的設(shè)計:在主界面中包括“輸入學(xué)生成績 顯示統(tǒng)計數(shù)據(jù) 查找學(xué)生成績 修改學(xué)生成績 刪除學(xué)生成績 插入學(xué)生成績 按平均分降序排列 顯示全部學(xué)生成績 退出本系統(tǒng)”等全部的功能,之所以設(shè)計這么一個主界面,一是因為能使用戶對程序操作的流程更加清楚簡明,二是保證了用戶同時只能對一個文件進(jìn)行操作的系統(tǒng)要求,保證了系統(tǒng)不會發(fā)生打開文件紊亂或者出現(xiàn)致命錯誤。每個函數(shù)的具體功能:1)主函數(shù)main():定義學(xué)生結(jié)構(gòu)體數(shù)組,調(diào)用錄入、統(tǒng)計等函數(shù)對成績表進(jìn)行處理;2)錄入函數(shù)Input():輸入班級到政治課成績;3)統(tǒng)計函數(shù)Statistic():計算平均成績;4)查詢函數(shù)Lookup():查詢指定學(xué)號學(xué)生成績記錄;5)修改函數(shù)Modify():修改指定學(xué)號學(xué)生成績記錄;6)刪除函數(shù)Delete():刪除指定學(xué)號學(xué)生記錄;7)輸出函數(shù)Output():輸出班級所有學(xué)生成績記錄;8) 排序函數(shù)Sort():按平均分對學(xué)生成績記錄項進(jìn)行降序排序;9)插入函數(shù)Insert():按平均分順序插入新記錄六、程序清單(另附電子版)#include#include#include#include#include#includeclass Stu /構(gòu)建學(xué)生類public:friend void Input(Stu stud) ;friend void Statistic(Stu stud);friend void Lookup(Stu stud) ;friend void Modify(Stu stud) ;friend void Delete(Stu stud) ;friend void Output(Stu stud) ;friend void Sort(Stu stud) ;friend void Insert(Stu stud) ;friend void Write(Stu stud,int n); friend int Read(Stu stud);friend void welcome();private:char class_020;int num;char name8;float elec;float c_program;float media;float english;float math;float sport;float polity;float average;int order;stud100;void welcome() /驗證用戶登陸,登陸成功顯示歡迎信息 char name4,code7;coutendl; coutendl; cout *n; cout 歡迎使用本學(xué)生成績管理系統(tǒng)!n; cout *n; cout編程人員:羅維權(quán) 劉威林 吳煒東endl; coutendl; cout請輸入用戶名和密碼:n; coutname; coutcode; while(strcmp(name,1111)!=0)|(strcmp(code,0000)!=0) coutnamecode; coutendl; coutendl; cout *n; cout 歡迎使用*系統(tǒng)!n; cout *n; coutendl;void Write(Stu stud,int n) /向文件中寫入數(shù)據(jù)fstream myFile;myFile.open(student.dat,ios:out|ios:binary);if(!myFile)coutstudent.dat cant open!endl;abort();int count=n;myFilecountendlendl;for(int i=0;i=count;i+)myFilestudi.class_0 studi.num studi.elec studi.c_program studi.media studi.english studi.math studi.sport studi.polity studi.averageendl; myFile.close();int Read(Stu stud) /從文件中讀數(shù)據(jù) fstream myFile; myFile.open(student.dat,ios:in|ios:binary); if(!myFile)coutstudent.dat cant open!count; for(int i=0;istudi.class_0studi.elecstudi.c_programstudi.mediastudi.englishstudi.mathstudi.sportstudi.politystudi.average; myFile.close(); return count ;void Input(Stu stud) /-輸入學(xué)生成績system(cls); /*運(yùn)行前清屏*/int i=0;int flag;char sign;coutendl 請輸入學(xué)生成績 =endl;while(sign!=n&sign!=N) /*判斷*/ coutstudi.class_0; loop:coutstudi.num;int c=0;while(ci)c+;if(studi.num=studi-c.num)cout 你輸入的學(xué)號已經(jīng)存在!請重新輸入。endl;goto loop;; doflag=0; coutstudi.elec; if(studi.elec100 |studi.elec1) cout對不起,請輸入1-100之間的數(shù)字!n; else flag=1;while(flag=0); do flag=0; coutstudi.c_program; if(studi.c_program100 |studi.c_program1) cout對不起,請輸入1-100之間的數(shù)字!n; else flag=1;while(flag=0); doflag=0;coutstudi.media; if(studi.media100 |studi.media1) cout對不起,請輸入1-100之間的數(shù)字!n; else flag=1;while(flag=0); doflag=0; coutstudi.english; if(studi.english100 |studi.english1) cout對不起,請輸入1-100之間的數(shù)字!n; else flag=1;while(flag=0); doflag=0;coutstudi.math; if(studi.math100 |studi.math1) cout對不起,請輸入1-100之間的數(shù)字!n; else flag=1;while(flag=0); doflag=0; coutstudi.sport; if(studi.sport100 |studi.sport1) cout對不起,請輸入1-100之間的數(shù)字!n; else flag=1;while(flag=0); doflag=0; coutstudi.polity; if(studi.polity100 |studi.polity1) cout對不起,請輸入1-100之間的數(shù)字!n; else flag=1;while(flag=0); studi.average=(studi.elec+studi.c_program+studi.media+studi.english+studi.math+studi.sport+studi.polity)/7; cout平均分為:studi.averageendl; cout提示:是否繼續(xù)寫入學(xué)生成績?(Y/N); cinsign; /*輸入判斷*/ i+; Write(stud,i);void Statistic(Stu stud) /-統(tǒng)計學(xué)生數(shù)據(jù) system(cls); /*運(yùn)行前清屏*/ int n=Read(stud);coutendl 輸出學(xué)生統(tǒng)計數(shù)據(jù) =endl; cout班級 學(xué)號 姓名 平均分endl;for(int i=0;in;i+)coutstudi.class_0 studi.num studi.averageendl; system(pause); void Lookup(Stu stud) /-查找學(xué)生成績 system(cls); /*運(yùn)行前清屏*/ int n=Read(stud);int s; int i=0;coutendl 查找學(xué)生成績 =endl;cout請輸入需要查找學(xué)生的學(xué)號:s; while(studi.num-s)!=0&in) i+; /*查找判斷*/ if(i=n) cout提示:對不起,無法找到該學(xué)生的信息!endl; /*輸入失敗信息*/ elsecout-endl; cout班級:studi.class_0endl; /*輸出該學(xué)生信息*/ cout學(xué)號:studi.numendl; cout姓名:endl; cout數(shù)據(jù)結(jié)構(gòu):studi.elecendl; coutC+程序設(shè)計:studi.c_programendl; cout大學(xué)語文:studi.mediaendl; cout大學(xué)英語:studi.englishendl; cout概率統(tǒng)計:studi.mathendl; cout大學(xué)體育:studi.sportendl; cout毛澤東思想:studi.polityendl; cout平均分:studi.averageendl;void Modify(Stu stud) /-修改學(xué)生成績 system(cls); /*運(yùn)行前清屏*/ int n=Read(stud);int s; int i=0;coutendl 修改學(xué)生成績 =endl;cout請輸入需要修改成績學(xué)生的學(xué)號:s; while(studi.num-s)!=0&in) i+; /*查找判斷*/ if(i=n) cout提示:對不起,無該學(xué)生的成績endl; /*輸入失敗信息*/ elsecout-該學(xué)生的信息-endl; /*格式頭*/ cout班級 學(xué)號 姓名 數(shù)據(jù) c+ 語文 英語 概率 體育 政治 平均分endl;cout-endl; coutstudi.class_0 studi.num studi.elec studi.c_program studi.media studi.english studi.math studi.sport studi.polity studi.averageendl;cout請重新輸入該學(xué)生的信息endl;cout班級:studi.class_0; cout學(xué)號:studi.num; cout姓名:; cout數(shù)據(jù)結(jié)構(gòu)成績:studi.elec; coutC+程序設(shè)計成績:studi.c_program; cout大學(xué)語文成績:studi.media; cout大學(xué)英語成績:studi.english; cout概率統(tǒng)計成績:studi.math; cout大學(xué)體育成績:studi.sport; cout毛澤東思想成績:studi.polity; studi.average=(studi.elec+studi.c_program+studi.media+studi.english+studi.math+studi.sport+studi.polity)/7; cout平均分為:studi.averageendl; char c; cout是否保存數(shù)據(jù)?(y/n)c; if(c!=n&c!=N) Write(stud,n);void Delete(Stu stud) /-按學(xué)號查找,刪除學(xué)生信息 system(cls); /*運(yùn)行前清屏*/ int n=Read(stud);int s; int i=0,j;coutendl 刪除學(xué)生成績 =endl;cout請輸入需要刪除學(xué)生的學(xué)號:s; while(studi.num-s)!=0&in) i+; /*查找判斷*/ if(i=n) cout提示:對不起,無法找到該學(xué)生endl; /*返回失敗信息*/ elsefor(j=i;jn-1;j+) /*刪除操作*/ strcpy(studj.class_0,studj+1.class_0); studj.num=studj+1.num; strcpy(,studj+1.name); studj.elec=studj+1.elec; studj.c_program=studj+1.c_program; studj.media=studj+1.media; studj.english=studj+1.english; studj.math=studj+1.math; studj.sport=studj+1.sport; studj.polity=studj+1.polity;studj.average=studj+1.average;cout提示:已成功刪除!endl; /*返回成功信息*/ Write(stud,n-1); void Insert(Stu stud) /-增加學(xué)生成績 system(cls); /*運(yùn)行前清屏*/int n=Read(stud);char s;coutendl 增加學(xué)生成績=endl;while(s!=n&s!=N)cout班級:studn.class_0; coutstudn.num; ; coutstudn.elec; coutstudn.c_program; coutstudn.media; coutstudn.english; coutstudn.math; coutstudn.sport; coutstudn.polity; studn.average=(studn.elec+studn.c_program+studn.media+studn.english+ studn.math+studn.sport+studn.polity)/7; cout平均分studn.average;n+; cout提示:插入成功!endl; /*返回成功信息*/cout是否繼續(xù)輸入(y/n)s;Write(stud,n); void Sort(Stu stud) /-按平均分對學(xué)生成績記錄項進(jìn)行降序排序 system(cls); /*運(yùn)行前清屏*/ int i,j,k; float s; char t20;coutendl 降序排序成績 =endl;int n=Read(stud);for(i=0;in-1;i+) /*冒泡法排序*/ for(j=0;jn-1-i;j+) if(studj.averagestudj+1.average) strcpy(t,studj+1.class_0); strcpy(studj+1.class_0,studj.class_0); strcpy(studj.class_0,t); k=studj+1.num; studj+1.num=studj.num; studj.num=k; strcpy(t,studj+1.name); strcpy(studj+1.name,); strcpy(,t); s=studj+1.elec; studj+1.elec=studj.elec; studj.elec=s; s=studj+1.c_program; studj+1.c_program=studj.c_program; studj.c_program=s; s=studj+1.media; studj+1.media=studj.media; studj.media=s; s=studj+1.english; studj+1.english=studj.english; studj.english=s; s=studj+1.math; studj+1.math=studj.math; studj.math=s; s=studj+1.sport;studj+1.sport=studj.sport; studj.sport=s; s=studj+1.polity; studj+1.polity=studj.polity; studj.polity=s; s=studj+1.average; studj+1.average=studj.average; studj.average=s; cout-endl; /*格式頭*/ coutsetw(6)班級setw(6)學(xué)號setw(6)姓名setw(6)數(shù)據(jù)setw(6)C+setw(6)語文setw(6)英語setw(6)概率setw(6)體育setw(6)政治 setw(6)平均分setw(6)名次endl; cout-endl; for(i=0;in;i+) /*循環(huán)輸入*/ studi.order=i+1;coutsetw(6)studi.class_0setw(6)studi.numsetw(6)setw(6)studi.elecsetw(6)studi.c_programsetw(6)studi.mediasetw(6)studi.englishsetw(6) studi.mathsetw(6)studi.sportsetw(6)studi.polity setw(6)setprecision(4)studi.averagesetw(6)studi.orderendl; Write(stud,n);void Output(Stu stud) /-顯示全部學(xué)生成績 system(cls); /*運(yùn)行前清屏*/int n=Read(stud);coutendl 顯示全部學(xué)生成績 =endl;if(!stud)cout沒有記錄; elsecout-endl; /*格式頭*/ coutsetw(6)班級setw(6)學(xué)號setw(6)姓名setw(6)數(shù)據(jù)setw(6)C+setw(6)語文setw(6)英語setw(6)概率setw(6)體育setw(6)政治 setw(6)平均分endl; cout-endl; for(int i=0;in;i+) /*循環(huán)輸入*/ coutsetw(6)studi.class_0setw(6)studi.numsetw(6)setw(6)studi.elecsetw(6)studi.c_programsetw(6)studi.mediasetw(6)studi.englishsetw(6) studi.mathsetw(6)studi.sportsetw(6)studi.polity setw(6)setprecision(4)studi.averageendl; cout-endl; int menu() /*菜單函數(shù)*/ char c; do void welcome();system(cls); /*運(yùn)行前清屏*/ cout*nendl; cout -歡迎您使用學(xué)生成績管理系統(tǒng)-nendl; cout編程人員:羅維權(quán) 劉威林 吳煒東endl; cout *nnendl;/*菜單選擇*/ cout * 【1】輸入學(xué)生成績 * endl; cout * 【2】顯示統(tǒng)計數(shù)據(jù) * endl; cout * 【3】查找學(xué)生成績 * endl; cout * 【4】修改學(xué)生成績 * endl; cout * 【5】刪除學(xué)生成績 * endl; cout * 【6】插入學(xué)生成績 * endl; cout * 【7】按平均分降序排列 * endl; cout * 【8】顯示全部學(xué)生成績 * endl; cout * 【0】退出本系統(tǒng) * endlendl; cout*endl; cout請你選擇操作(0-8):endl; c=getchar(); /*讀入選擇*/ while(c8); return(c-0); /*返回選擇*/ void main() /*主函數(shù)*/ welcome();for(;) switch(menu() /*選擇判斷*/ case 1: Input(stud);/*輸入學(xué)生成績*/ break; case 2: Statistic(stud); /*輸出學(xué)生統(tǒng)計數(shù)據(jù)*/ break; case 3: Lookup(stud); /*查找學(xué)生成績*/ coutttt; system(pause); break; case 4: Modify(stud); /*修改學(xué)生成績*/ coutttt; system(pause); break; case 5: Delete(stud); /*按學(xué)號查找,刪除學(xué)生信息*/ coutttt; system(pause); break; case 6: Insert(stud);/*增加學(xué)生成績*/ coutttt; system(pause); break; case 7: Sort(stud); /*按平均分對成績記錄項進(jìn)行降序排序*/ coutttt; system(pause); break; case 8: Output(stud); /*顯
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 銷售稅務(wù)常識培訓(xùn)課件
- 健康飲食產(chǎn)業(yè)園項目質(zhì)量管理方案(參考)
- 2025年雙門轎跑車合作協(xié)議書
- 2025年汽車尾氣自動測定儀合作協(xié)議書
- 鄉(xiāng)城流動中的中國男性婚姻擠壓緒論
- 2025年臨床前CRO項目發(fā)展計劃
- 物業(yè)服務(wù)委托合同 (二)
- 2025年無機(jī)電子材料合作協(xié)議書
- 2025年黑龍江省中考生物試卷(含答案)
- 2025年閑置物品調(diào)劑回收項目合作計劃書
- 二手車買賣合同電子版下載
- 外科考試題庫及復(fù)習(xí)資料(唐都醫(yī)院)
- YS/T 534.5-2007氫氧化鋁化學(xué)分析方法第5部分:氧化鈉含量的測定
- GB/T 8269-2006檸檬酸
- GB/T 5267.2-2002緊固件非電解鋅片涂層
- 儀表實(shí)操題集
- 2022年??谕顿Y管理有限公司招聘筆試試題及答案解析
- 青藍(lán)工程師傅心得體會
- 風(fēng)機(jī)基礎(chǔ)錨栓安裝技術(shù)交底
- 2022更新國家開放大學(xué)電大《調(diào)劑學(xué)》網(wǎng)絡(luò)核心課形考網(wǎng)考作業(yè)及答案
- 廣西鼎固經(jīng)緯新材料科技有限公司年加工50萬噸礦粉生產(chǎn)項目環(huán)評報告表
評論
0/150
提交評論