C++학교 운동회 관리 시스템 의 실현

본 논문 의 사례 는 C++운동회 관리 시스템 을 실현 하 는 구체 적 인 코드 를 공유 하여 여러분 께 참고 하 시기 바 랍 니 다.구체 적 인 내용 은 다음 과 같 습 니 다.

#include <iostream>
#include <cstdio>
#include <string>
#include <windows.h>
#include <set>
#include <map>
using namespace std;
const int MAXN = 100005;
typedef long long LL;
map< pair<string, string>, int> mtable;//      
map< pair<string, string>, int> wtable;//      
multimap<string, string> parti;//        
set <string> st;//       
map<string, int> mitem;//          
map<string, int> witem;//          
map<string, int> item;//       
map<string, int> acad;//      
map<string, int> macad;//      
map<string, int> wacad;//      
int cnt;
struct student
{
 string number;
 string name;
 string acad;
 string sex;
 int participate;
} stu[MAXN];
void menu()
{
 cout<<"**************       *****************
"; cout<<"1.
"; cout<<"2.
"; cout<<"3.
"; cout<<"4.
"; cout<<"5.
"; cout<<"6.
"; cout<<"7.
"; return ; } void apply()// { system("cls"); string s1,s2,s3,s4,s5; cout<<"
"; cout<<" , , , ,
"; cin>>s1>>s2>>s3>>s4>>s5; if(st.find(s3)==st.end()) { stu[cnt].acad=s1; stu[cnt].name=s2; stu[cnt].number=s3; stu[cnt].sex=s4; stu[cnt++].participate++; st.insert(s3); } else { for(int i=0; i<cnt; ++i) { if(s3==stu[i].number) { if(stu[i].participate+1<=3) stu[i].participate++; else { printf(" 3 ,
"); return ; } } } } parti.insert(make_pair(s3,s5)); acad.insert(make_pair(s1,0)); item[s5]++; if(s4==" ") { mitem[s5]=mitem[s5]+1; macad.insert(make_pair(s1,0)); mtable[pair<string, string>(s3,s5)]=0; } else { witem[s5]=witem[s5]+1; wacad.insert(make_pair(s1,0)); wtable[pair<string, string>(s3,s5)]=0; } return ; } void query()// { printf("
"); for(int i=0; i<cnt; ++i) { cout<<" "<<stu[i].number<<" "<<" "<<stu[i].name<<" "<<" "<<stu[i].sex<<" "<<" "<<stu[i].acad<<" "<<" "<<stu[i].participate<<endl;; cout<<" :"<<" "<<stu[i].name<<" "<<"
"; multimap<string,string>::iterator it=parti.begin(); for(; it!=parti.end(); it++) { if(it->first==stu[i].number) { cout<<it->second<<" "; } } cout<<"
"; } return ; } void registration()// { system("cls"); cout<<" "<<endl; string s; cin>>s; cout<<" "<<"
"; int flag=0; multimap<string, string>::iterator it = parti.begin(); for(; it!=parti.end(); ++it) { if(it->second==s) { flag=1; cout<<it->first<<endl; } } if(!flag) cout<<"
"<<endl; return ; } void record()// { printf(" ,
"); string s1,s2; int grade, ans=0; cin>>s1>>s2>>grade; for(int i=0; i<cnt; ++i) { if(stu[i].number==s1) { if(stu[i].sex==" ") { if(mitem[s2]>6) { if(grade==1) ans=7; else if(grade==2) ans=5; else if(grade==3) ans=3; else if(grade==4) ans=2; else if(grade==5) ans=1; else ans=0; } else { if(grade==1) ans=5; else if(grade==2) ans=3; else if(grade==3) ans=2; else ans=0; } macad[stu[i].acad]+=ans; mtable[pair<string,string>(s1,s2)]=ans; } else { if(witem[s2]>6) { if(grade==1) ans=7; else if(grade==2) ans=5; else if(grade==3) ans=3; else if(grade==4) ans=2; else if(grade==5) ans=1; else ans=0; } else { if(grade==1) ans=5; else if(grade==2) ans=3; else if(grade==3) ans=2; else ans=0; } wacad[stu[i].acad]+=ans; wtable[pair<string, string>(s1,s2)]=ans; } acad[stu[i].acad]+=ans; } } } void menu2() { cout<<"1.
"; cout<<"2.
"; cout<<"3.
"; cout<<"4.
"; cout<<"
"; return ; } void query_contest1() { map<string, int>::iterator it=acad.begin(); for(; it!=acad.end(); ++it) { cout<<" :"<<it->first<<endl; for(int i=0; i<cnt; ++i) { if(stu[i].acad==it->first) { multimap<string, string>::iterator iter=parti.begin(); for(; iter!=parti.end(); ++iter) { if(stu[i].number!=iter->first) continue; if(stu[i].sex==" ") cout<<" : "<<stu[i].name<<" : "<<iter->second<<" : "<<mtable[pair<string,string>(iter->first,iter->second)]<<endl; else cout<<" : "<<stu[i].name<<" : "<<iter->second<<" : "<<wtable[pair<string,string>(iter->first,iter->second)]<<endl; } } } } } void query_contest2() { map<string, int>::iterator it=item.begin(); for(; it!=item.end(); it++) { cout<<" :"<<it->first<<endl; multimap<string, string>::iterator iter=parti.begin(); for(; iter!=parti.end(); iter++) { if(iter->second==it->first) { for(int i=0; i<cnt; ++i) { if(iter->first==stu[i].number) { if(stu[i].sex==" ") cout<<" : "<<stu[i].name<<" : "<<iter->second<<" : "<<mtable[pair<string,string>(iter->first,iter->second)]<<endl; else cout<<" : "<<stu[i].name<<" : "<<iter->second<<" : "<<wtable[pair<string,string>(iter->first,iter->second)]<<endl; } } } } } } void query_contest3() { for(int i=0; i<cnt; ++i) { cout<<" : "<<stu[i].name<<"
"; multimap<string, string>::iterator iter=parti.begin(); for(; iter!=parti.end(); iter++) { if(iter->first==stu[i].number) { if(stu[i].sex==" ") cout<<" : "<<iter->second<<" : "<<mtable[pair<string,string>(iter->first,iter->second)]<<endl; else cout<<" : "<<iter->second<<" : "<<wtable[pair<string,string>(iter->first,iter->second)]<<endl; } } } } void query_contest()// { system("cls"); menu2(); int op; if(cnt==0) { printf(" ,
"); return ; } scanf("%d", &op); switch(op) { case 1: query_contest1(); break; case 2: query_contest2(); break; case 3: query_contest3(); break; case 4: return; break; default: printf(" ,
"); } } void sort_contest()// { int Size=acad.size(); for(int i=0; i<Size; ++i) { int Max=-1; string Maxs=""; map<string, int >::iterator it = acad.begin(); map<string, int >::iterator iter; for(; it!=acad.end(); ++it) { if(Max<it->second) { Max=it->second; Maxs=it->first; iter=it; } } acad.erase(iter); cout<<" :"<<Maxs<<" :"<<Max<<endl; cout<<" :"<<macad[Maxs]<<" "<<wacad[Maxs]<<endl; } } int main() { int op; cout<<("************** *****************
"); // printf(" ,
"); // scanf("%d %d %d", &c, &n, &m); // if(c<0||n<0||m<0) // { // printf(" ,
"); // scanf("%d %d %d", &c, &n, &m); // } cnt=0; while(1) { menu(); scanf("%d", &op); switch(op) { case 1: apply(); break; case 2: query(); break; case 3: registration(); break; case 4: record(); break; case 5: query_contest(); break; case 6: sort_contest(); break; case 7: return 0; break; default: cout<<" ,
"; break; } } return 0; }
효과 그림:


이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기