學生成績管理系統(tǒng)c源程序_第1頁
學生成績管理系統(tǒng)c源程序_第2頁
學生成績管理系統(tǒng)c源程序_第3頁
學生成績管理系統(tǒng)c源程序_第4頁
學生成績管理系統(tǒng)c源程序_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、C+程序設(shè)計源程序: 學生成績管理系統(tǒng)#in clude#in clude#i nclude #include /數(shù)組比較頭文件#include 文件的輸入輸出#i nclude int time=0;char n ame_20;class CPersonCPerson 基類 成員:IDNo Name Addr Telpublic:char IDNo30;char Name30;char Addr30;char Tel30;Averageclass CStudent:public CPerson/-CStudent 類-繼承自 CPerson 成員:StudNo MathEnglishpubl

2、ic:char StudNo30;double Math;double En glish;double Average;class CClass/CClass 類 成員:CClassName CStudentprivate:char CCIassName30;CStude nt* stu50;public:CClass();CCIass();void CreateClass(); /void OutClassName(); 輸出班級名字void NewAStu();/1.創(chuàng)建學生信息void chan ge();/3.修改學生信息void del();4.刪除學生信息void writei n

3、();/ 文件寫入void writeout();/ 文件讀出void writei no();/ 文件另存為void writeouto();/打開其他文件void fin d();/6.查詢學生信息 ;void back()/屈9頻函數(shù)coutttt 執(zhí)行成功!endl;system(pause);/ 任意鍵繼續(xù)system(cls);/ 清除屏幕void back_ no()system(pause);/ 任意鍵繼續(xù)system(cls);/ 清除屏幕void title()/system(cls);cout;void CCIass:writein()保存文件ofstream SaveF

4、ile(myfile.txt);SaveFileCCIassNamettimee ndl;for(i nt i=0;itime;i+)SaveFileIDNotNametAddrtTeltStudNotMathtE nglishtAveragee ndl;SaveFile.close();ofstream Save(n ame_);SaveCClassNamettimee ndl;for(i nt j=O;jtime;j+)SaveIDNotNametAddrtTeltStudNotMathtE nglishtAveragee ndl;Save.close();void CCIass:writ

5、eino() 文件另存為char choice30;ofstream fop;ifstream fip;cout文件已默認保存了 !t現(xiàn)在需要另存為?(Y/N) choice;while(strcmp(choice,Y)=0|strcmp(choice,y)=0)cout請輸入文件名稱:tendl;cinn ame_;strcat (n ame_, .txt );fop.ope n(n ame_);fopCCIassNamettimee ndl;for(i nt i=0;itime;i+)fopIDNotNametAddrtTeltStudNotMathtE nglishtAveragee n

6、dl;fip.close();cout另存為name_成功!endl;back_ no ();return;while(strcmp(choice, n)=0|strcmp(choice,N)=0)back_ no ();return;while(strcmp(choice,Y)!=0|strcmp(choice,y)!=0)cout輸入錯誤!endl;back_ no ();return;void CCIass:writeout()int i=0;char c30;FILE *fp;if(fp=fope n( myfile.txt,r)=NULL)coutca nnt ope n the f

7、ilen;exit(0);fsca nf(fp,%s%d,c, &time);strcpy(CClassName,c);while(iIDNo,stui-Name,stui-Addr, &stui-Tel,stui-StudNo,&stui-Math, &stui-E nglish, &stui-Average);i+;fclose(fp); /* 關(guān)閉文件 */cout恭喜你!成功讀取班級信息!n;void CClass:writeouto() /打開其他文件int i=0;char c30;FILE *fp;fstream _file;ofstream fop;ifstream fip;c

8、out請輸入文件名稱:tendl;cinn ame_;strcat( name_, .txt );/ 創(chuàng)建文件名ifstream fin(n ame_);_file.ope n(n ame_,ios:i n);while(!_file)coutname_沒有被創(chuàng)建 n;cout請輸入文件名稱:tendl;cinn ame_;if(fp=fope n(n ame_,r)=NULL)coutca nnt ope n the filen;exit(O);fsca nf(fp,%s%d,c, &time);strcpy(CCIassName,c);while(iIDNo,stui-Name,stui-

9、Addr, &stui-Tel,stui-StudNo, &stui-Math, &stui-E nglish, &stui-Average);i+;fclose(fp); /* 關(guān)閉文件 */cout恭喜你!成功讀取班級信息!n;CCIass:CCIass()for(i nt i=0;i50;i+)stui=new CStude nt();CCIass:CCIass()for(i nt i=0;i50;i+)delete stui;void CCIass:CreateClass()創(chuàng)建班級char choice30;char *c;char cn ame30;cout 學生信息管理程序 en

10、dl;cout1、創(chuàng)建班級endl2、讀取班級信息endl3、退出程序endl;cout choice;for(i nt o=0;o100;o+)while(strcmp(choice,1)=0)system(cls);cout 學生信息管理程序 endl;cout c;strcpy(CCIassName,c);return;while(strcmp(choice,2)=0)system(cls);title();coutn1、打開上次的文件 endl2、打開其他文件endln 請選擇:;cincn ame;for(i nt k=0;k100;k+)while(strcmp(c name,1)

11、=0)writeout();return;while(strcmp(c name,2)=0)writeouto();return;cout請在12中選擇:;cincn ame;while(strcmp(choice,0)=0)exit(0);cout choice;void CCIass:NewAStu()0.創(chuàng)建學生cout輸入學生信息n;coutstutime-IDNo;/檢驗身份證位數(shù)while(stutime-IDNo18!=0)coutstutime-IDNo;cout stutime-Name;cout stutime-Addr;cout stutime-Tel;coutstuti

12、me-StudNo;for(int o=0;oStudNo12!=0)/檢驗學號位數(shù)coutstutime-StudNo;for(int i=0;iStudNo,stutime-StudNo)=0)coutstutime-StudNo;cout stutime-Math;while(stutime-MathMath100)cout stutime-Math;cout stutime-E nglish;while(stutime-E nglishE nglish100)cout stutime-E nglish;stutime-Average=(stutime-Math+stutime-E ng

13、lish)/2; back();void CCIass:OutClassName()2.打印班級名稱int fen shu; char temp30;double temp_;for(i nt cha nge=0;cha ngetime;cha nge+)fen shu=cha nge;for(i nt j=cha nge;jStudNo,stufe nshu-StudNo)Addr); strcpy(stufe nshu-Addr,stucha nge-Addr); strcpy(stuchange-Addr,temp); /* 地址 */ strcpy(temp,stufe nshu-St

14、udNo);strcpy(stufe nshu-StudNo,stucha nge-StudNo); strcpy(stuchange-StudNo,temp); /* 身份證 */ strcpy(temp,stufe nshu-Name);strcpy(stufe nshu-Name,stucha nge-Name); strcpy(stuchange-Name,temp); /* 姓名 */ strcpy(temp,stufe nshu-Tel);strcpy(stufe nshu-Tel,stucha nge-Tel); strcpy(stuchange-Tel,temp); /* 電話

15、 */ strcpy(temp,stufe nshu-IDNo);strcpy(stufe nshu-IDNo,stucha nge-IDNo); strcpy(stuchange-IDNo,temp); /* 學號 */ temp_=stufe nshu-Math;stufe nshu-Math=stucha nge-Math; stuchange-Math=temp_; /* 數(shù)學 */ temp_=stufe nshu-E nglish;stufe nshu-E nglish=stucha nge-E nglish; stuchange-English=temp_; /* 英語 */ t

16、emp_=stufe nshu-Average;stufe nshu-Average=stucha nge-Average; stuchange-Average=temp_; /* 平均分 */平均分endl;coutn 班級名稱:CCIassNamet人數(shù):timeendlendl;cout 學號身份證號碼姓名 住址 電話 數(shù)學 英語for(i nt i=0;itime;i+)coutStudNoIDNoNameAddrTeltMathtE nglish tAveragee ndl;back_ no();void CCIass:change()3.修改學生的信息char str30;int

17、i,had=0;char *a;char x30;if(time!=0)cout str;for(i=0;i50;i+)coutt身份證號碼t姓名t住址t電話t學號t數(shù)學成績t英語成績tStudNo,str)=0|strcmp(stui-Name,str)=0) :tIDNoe ndl:tNamee ndl:tAddre ndl:tTele ndl:tStudNoe ndl:tMath:tE nglish:tAveragee ndle ndle ndl;e ndl;e ndl;cout1、修改地址endl; cout2、修改電話號碼 cout3、修改數(shù)學成績 cout4、修改英語成績 cout

18、0、返回endl; cout x;for(i nt k=0;k100;k+)while(strcmp(x,1)=0)cout a;strcpy(stui_Addr,a); back();return;while(strcmp(x,2)=0)cout stui_Tel;back();return;while(strcmp(x,3)=0)coutstui-Math;while(stui-Math100|stui-Math0)coutMath;stui-Average=(stui-Math+stui-E nglish)/2; back();return;while(strcmp(x,4)=0)cou

19、t stui-E nglish;while(stui-E nglish100|stui-E nglish0)coutEnglish;stui-Average=(stui-Math+stui-E nglish)/2; back();return;cout x;if(had=O)cout對不起!沒有查詢到str的信息!endl; back_ no();void CCIass:del()4.刪除學生的信息char str30;int i,had=0;if(time!=0)cout str;for(i=0;iStudNo,str)=0)had=1;cout第i+l位學生:endl;coutt身份證號碼

20、:tIDNoendlt姓名t住址t電話t學號t數(shù)學成績t英語成績t平均分tNamee ndl tAddre ndl tTele ndl tStudNoe ndl tMathe ndl tE nglishe ndl tAveragee ndle ndl;for(i nt j=i;jIDNo,stuj+1-IDNo); strcpy(stuj-Name,stuj+1-Name); strcpy(stuj-Addr,stuj+1-Addr); strcpy(stuj-Tel,stuj+1-Tel);strcpy(stuj-StudNo,stuj+1-StudNo); stuj-Math=stuj+1

21、-Math;stuj-E nglish=stuj+1-E nglish;stuj-Average=stuj+1-Average; back();time=time-1;if(had=0)cout對不起!沒有查詢到str的信息!endl; back_ no();void CClass:find()/6.查詢學生的信息char str30;cout str;for(i nt i=0;iIDNo,str)=0|strcmp(stui-StudNo,str)=0|strcmp(stui-Tel,str)=O)coutnt身份證號碼:tIDNoendltt t t t t t姓名住址電話學號數(shù)學成績英語成績平均分tNamee ndl tAddre ndl tTele ndl tStudNoe ndl tMath tE nglish tAveragee ndle ndl;back_ no (); return;cout對不起!沒有查詢到str的信息!endl;back_ no();void main()main 主函數(shù)system(ver);CClass ClassRoom; char select ion 30;ClassRoom.CreateClass();system(cls);for(int o=0;o1000;o+

溫馨提示

  • 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

提交評論