本文實(shí)例為大家分享了C++運(yùn)動會管理系統(tǒng)的實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下
創(chuàng)新互聯(lián)建站自2013年創(chuàng)立以來,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢想脫穎而出為使命,1280元霍山做網(wǎng)站,已為上家服務(wù),為霍山各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108#include<iostream.h> #define MAX 10 #include<iomanip.h> #include "fstream.h" int n,m,w; class gamescore {public: int academynum; //院系編號 int score[MAX][MAX]; //記錄成績的2維數(shù)組 int totalscore[MAX]; //院總分存儲數(shù)組 int mentotalscore[MAX]; //男團(tuán)總分存儲數(shù)組 int womentotalscore[MAX];//女團(tuán)總分存儲數(shù)組 int projectnum; //項(xiàng)目編號 gamescore() { academynum=0; projectnum=0; } void search(int academynum,int projectnum); void remove(int academynum,int projectnum); void repair(int academynum,int projectnum); void save(); //保存成績 void input(); void sort1(); //按院總分排序 void sort2(); //按男團(tuán)總分排序 void sort3(); //按女團(tuán)總分排序 void hold(); //存儲總分?jǐn)?shù) int academytotalscore(int academynum); //院總分 int academywomentotalscore(int academynum); //院女團(tuán)總分 int academymentotalscore(int academynum); //院男團(tuán)總分 void output1(int academy); //輸出院系的成績列表 void output2(int academynum); //輸出院系的團(tuán)體成績列表 }; void gamescore::input() { int i,j; for(i=0;i<n;i++) { cout<<"輸入編號為"<<i+1<<"院系的成績(若參賽人數(shù)超過6人,取前5名:第1名得分 7,第2名得分 5,第3名得分3,第4名得分2,第5名得分 1,否則參賽院系不超過6個(gè),每項(xiàng)目取前三名,分別為5,3,2分,其余記成績?yōu)?)"<<endl; for(j=0;j<m+w;j++) { cout<<"輸入編號為"<<i+1<<"院系的的運(yùn)動項(xiàng)目編號為"<<j+1<<"的成績:"; cin>>score[i][j]; if(score[i][j]!=0&&score[i][j]!=2&&score[i][j]!=5&&score[i][j]!=10) { cout<<"成績輸入錯(cuò)誤,請檢查后再輸入"<<endl; cin>>score[i][j]; } } } if(i=n-1) cout<<"!!輸入完畢"<<endl; } void gamescore::save() { ofstream ofs("運(yùn)動會成績.txt"); ofs<<"將最終學(xué)院參加的對應(yīng)項(xiàng)目成績列表列出(行表示學(xué)院編號,列表示項(xiàng)目編號)"<<endl; for(int i=0;i<n;i++) { for(int j=0;j<m+w;j++) { ofs<<score[i][j]<<setw(5); } ofs<<endl; } for(i=1;i<=n;i++) { ofs<<"編號為"<<i<<"的學(xué)院總分的成績?yōu)?"<<academytotalscore(i)<<endl; ofs<<"編號為"<<i<<"的學(xué)院男團(tuán)的成績?yōu)?"<<academymentotalscore(i)<<endl; ofs<<"編號為"<<i<<"的學(xué)院女團(tuán)的成績?yōu)?"<<academywomentotalscore(i)<<endl; } ofs.close(); } int gamescore::academytotalscore(int academynum)//院總分 { int sum=score[academynum-1][0]; for(int i=1;i<m+w;i++) { sum=sum+score[academynum-1][i]; } return sum; } int gamescore::academywomentotalscore(int academynum)//院女團(tuán)總分 { int sum=score[academynum-1][m]; for(int i=m+1;i<m+w;i++) { sum=sum+score[academynum-1][i]; } return sum; } int gamescore::academymentotalscore(int academynum)//院男團(tuán)總分 { int sum=score[academynum-1][0]; for(int i=1;i<m;i++) { sum=sum+score[academynum-1][i]; } return sum; } void gamescore::hold()//存儲總分 { for(int i=1;i<=n;i++) { totalscore[i-1]=academytotalscore(i); mentotalscore[i-1]=academymentotalscore(i); womentotalscore[i-1]=academywomentotalscore(i); } } void gamescore::sort1()//按院系總分排序 { int p,q; int a[MAX]; for(int i=0;i<n;i++) { a[i]=i+1; } for(int j=0;j<n-1;j++) { for(i=0;i<=n-1-j;i++) { if(totalscore[i]<totalscore[i+1]) { p=totalscore[i]; totalscore[i]=totalscore[i+1]; totalscore[i+1]=p; q=a[i]; a[i]=a[i+1]; a[i+1]=q; } } } cout<<"按院系總分從大到小排序,以及對應(yīng)的院系編號為:"<<endl; for(j=0;j<n;j++) { cout<<a[j]<<setw(5); } cout<<endl; for(j=0;j<n;j++) { cout<<totalscore[j]<<setw(5); } cout<<endl; } void gamescore::sort2()//按男團(tuán)總分排序 { int p,q; int a[MAX]; for(int i=0;i<n;i++) { a[i]=i+1; } for(int j=0;j<n-1;j++) { for(i=0;i<=n-1-j;i++) { if(mentotalscore[i]<mentotalscore[i+1]) { p=mentotalscore[i]; mentotalscore[i]=mentotalscore[i+1]; mentotalscore[i+1]=p; q=a[i]; a[i]=a[i+1]; a[i+1]=q; } } } cout<<"按男團(tuán)總分從大到小排序,以及對應(yīng)的院系編號為:"<<endl; for(j=0;j<n;j++) { cout<<a[j]<<setw(5); } cout<<endl; for(j=0;j<n;j++) { cout<<mentotalscore[j]<<setw(5); } cout<<endl; } void gamescore::sort3()//按女團(tuán)總分排序 { int p,q; int a[MAX]; for(int i=0;i<n;i++) { a[i]=i+1; } for(int j=0;j<n-1;j++) { for(i=0;i<=n-1-j;i++) { if(womentotalscore[i]<womentotalscore[i+1]) { p=womentotalscore[i]; womentotalscore[i]=womentotalscore[i+1]; womentotalscore[i+1]=p; q=a[i]; a[i]=a[i+1]; a[i+1]=q; } } } cout<<"按女團(tuán)總分從大到小排序,以及對應(yīng)的院系編號為:"<<endl; for(j=0;j<n;j++) { cout<<a[j]<<setw(5); } cout<<endl; for(j=0;j<n;j++) { cout<<womentotalscore[j]<<setw(5); } cout<<endl; } void gamescore::search(int academynum,int projectnum) {int j; int k; do { cout<<"1 查詢該院該單項(xiàng)成績的總分, 2 查詢該院總分,,3 查詢該院男團(tuán)總分,4 查詢該院女團(tuán)總分,5 按項(xiàng)目編號查詢,0 退出查詢"<<endl; cout<<"請選擇:"; cin>>k; if(k<0||k>5) //判斷輸入的操作編號是否在目錄中,如果超出范圍重新輸入 { cout<<"輸入有誤,請重新輸入要操作的項(xiàng)目編號"; cin>>k; } switch(k) { case 1: cout<<"編號為"<<academynum<<"的學(xué)院的第"<<projectnum<<"個(gè)項(xiàng)目的成績?yōu)?"; cout<<score[academynum-1][projectnum-1]<<endl;break; case 2: cout<<"該院總分為:"<<academytotalscore(academynum)<<endl;break; case 3: cout<<"該院男團(tuán)總分為:"<<academymentotalscore(academynum)<<endl;break; case 4: cout<<"該院女團(tuán)總分:"<<academywomentotalscore(academynum)<<endl;break; case 5: cout<<"不同院系對應(yīng)的第"<<projectnum<<"個(gè)項(xiàng)目的成績?yōu)?"<<endl; for(j=0;j<n;j++) { cout<<1+j<<setw(5); } cout<<endl; for(j=0;j<n;j++) { cout<<score[j][projectnum-1]<<setw(5); } cout<<endl; break; default: return; } }while(1); } void gamescore::repair(int academynum,int projectnum) { cout<<"請重新輸入該項(xiàng)成績:"; cin>>score[academynum-1][projectnum-1]; cout<<"修改成功"<<endl; } void gamescore::remove(int academynum,int projectnum) { score[academynum-1][projectnum-1]=0; cout<<"!!刪除成功"<<endl; } void gamescore::output1(int academynum) { //cout<<"該學(xué)院運(yùn)動項(xiàng)目編號及對應(yīng)的成績?nèi)缦拢?<<endl; for(int i=0;i<m+w;i++) { cout<<1+i<<setw(5); } cout<<endl; for(i=0;i<m+w;i++) { cout<<score[academynum-1][i]<<setw(5); } } void gamescore::output2(int academynum) { cout<<"該院男團(tuán)成績?yōu)?<<academymentotalscore(academynum)<<endl; cout<<"該院女團(tuán)成績?yōu)?<<academywomentotalscore(academynum)<<endl; } ///////////////////////////////////////////////////// void main() { int projectnum; int academynum; gamescore a; int num; ////////////////////////////////////////////菜單 cout<<" ****廣東海洋大學(xué)運(yùn)動會成績管理系統(tǒng)****"<<endl; cout<<endl; cout<<" **********************************************"<<endl; cout<<" ** 1 輸入院系及其參加項(xiàng)目的成績 **"<<endl; cout<<" ** 2 查詢某個(gè)院系參加某個(gè)項(xiàng)目的成績 **"<<endl; cout<<" ** 3 修改一個(gè)項(xiàng)目的成績 **"<<endl; cout<<" ** 4 刪除錯(cuò)誤成績的記錄 **"<<endl; cout<<" ** 5 輸出某個(gè)院系的得分表 **"<<endl; cout<<" ** 6 輸出院系的團(tuán)體得分表 **"<<endl; cout<<" ** 7 對成績按院系進(jìn)行排序 **"<<endl; cout<<" ** 8 對成績按男團(tuán)進(jìn)行排序 **"<<endl; cout<<" ** 9 對成績按女團(tuán)進(jìn)行排序 **"<<endl; cout<<" ** 10 保存成績信息 **"<<endl; cout<<" ** 0 退出該程序 **"<<endl; cout<<" **********************************************"<<endl<<endl; cout<<" 輸入?yún)⒓釉合禂?shù) n="; cin>>n; cout<<" 輸入男子項(xiàng)目數(shù) m="; cin>>m; cout<<" 輸入女子項(xiàng)目數(shù) w="; cin>>w; do{ cout<<"請選擇要操作的菜單標(biāo)號:"; cin>>num; if(num>10||num<0) { cout<<"輸入有誤,請重新輸入要操作的項(xiàng)目編號:"; cin>>num; } switch(num) { case 1: a.input(); break; case 2: cout<<"輸入要查找的院系:"; cin>>academynum; cout<<"輸入要查詢的運(yùn)動項(xiàng)目編號:"; cin>>projectnum; a.search(academynum,projectnum); break; case 3: cout<<"輸入要修改的院系編號"; cin>>academynum; cout<<"輸入要修改的運(yùn)動項(xiàng)目的編號:"; cin>>projectnum; a.repair(academynum,projectnum); break; case 4: cout<<"輸入要?jiǎng)h除成績所在的院系的編號:"; cin>>academynum; cout<<"輸入要?jiǎng)h除運(yùn)動項(xiàng)目編號:"; cin>>projectnum; a.remove(academynum,projectnum); break; case 5: cout<<"輸入要查詢成績的院系編號:"; cin>>academynum; a.output1(academynum); break; case 6: cout<<"輸入要查詢團(tuán)體成績的院系的編號:"; cin>>academynum; a.output2(academynum); break; case 7: cout<<"該學(xué)院運(yùn)動項(xiàng)目編號及對應(yīng)學(xué)院總分的成績?nèi)缦?"; a.hold(); a.sort1();break; case 8: cout<<"該學(xué)院運(yùn)動項(xiàng)目編號及對應(yīng)男團(tuán)的成績?nèi)缦?"; a.hold(); a.sort2();break; case 9: cout<<"該學(xué)院運(yùn)動項(xiàng)目編號及對應(yīng)女團(tuán)的成績?nèi)缦?"; a.hold(); a.sort3();break; case 10: a.save(); cout<<"!!保存成功"<<endl;break; default: return; } }while(1); }
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站m.rwnh.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
名稱欄目:C++課程設(shè)計(jì)之運(yùn)動會管理系統(tǒng)-創(chuàng)新互聯(lián)
本文URL:http://m.rwnh.cn/article28/hssjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、域名注冊、企業(yè)建站、網(wǎng)站維護(hù)、標(biāo)簽優(yōu)化、網(wǎng)站營銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容