#include <iostream>using namespacestd; #include"string"#include<vector>#include<list>#include"Set"#include<algorithm>#include"Functional"#include"iterator" //header file for output stream iterator#include <numeric>#include"Map"#include"deque"classspeaker{ Public: stringM_name; intm_score[3];//score of 3 rounds of the game};//Generation playerintGenspeaker (map<int, Speaker> &mapspeaker, vector<int> &v) { stringstr ="abcdefghijklmnopqrstuvwxyz"; Random_shuffle (Str.begin (), Str.end ()); for(intI=0; i< -; i++) {Speaker tmp; Tmp.m_name="Contestants"; Tmp.m_name= Tmp.m_name +Str[i]; Mapspeaker.insert (Pair<int, Speaker> ( -+I, TMP)); } for(intI=0; i< -; i++) {V.push_back ( -+i);//the person who participated in the competition } return 0;}//contestant DrawintSpeech_contest_draw (vector<int> &v) {Random_shuffle (V.begin (), V.end ()); return 0;}//contestant CompetitionintSpeech_contest (intIndex, vector<int> &v1, map<int, Speaker> &mapspeaker, vector<int> &v2) { //the score of the team's match is recorded; Find out the top three 3multimap<int,int, greater<int>> Multmapgroup;//Group Results intTmpcount =0; for(vector<int>::iterator It=v1.begin (); It!=v1.end (); it++) {Tmpcount++; //score{deque<int>Dscore; for(intj=0; j<Ten; J + +)//10 Judges score { intScore = -+rand ()% -; Dscore.push_back (score); } sort (Dscore.begin (), Dscore.end ()); Dscore.pop_back (); Dscore.pop_front (); //remove the lowest score highest score//calculate the average score intScoresum = Accumulate (Dscore.begin (), Dscore.end (),0); intScoreavg = scoresum/dscore.size (); mapspeaker[*it].m_score[index] = Scoreavg;//player score in containerMultmapgroup.insert (pair<int,int> (SCOREAVG, *it)); } //working with groupings if(Tmpcount%6==0) {cout<<"the team's competition results"<<Endl; for(multimap<int,int, greater<int>>::iterator Mit=multmapgroup.begin (); Mit!=multmapgroup.end (); mit++ ) { //Number name scorecout << Mit->second <<"\ t"<< Mapspeaker[mit->second].m_name <<"\ t"<< Mit->first <<Endl; } //top three promotion while(Multmapgroup.size () >3) {Multimap<int,int, greater<int>>::iterator it1 =Multmapgroup.begin (); V2.push_back (it1->second);//Put the top three on the V2 promotion list.multmapgroup.erase (IT1); } multmapgroup.clear (); //situation This group competition results } } return 0;};//View Tournament ResultsintSpeech_contest_print (intIndex, vector<int> &v, map<int, Speaker> &Mapspeaker) {printf ("round%d promotion list \ n", index+1); for(vector<int>::iterator It=v.begin (); It!=v.end (); it++) {cout<<"Entry Number:"<< *it <<"\ t"<< Mapspeaker[*it].m_name <<"\ t"<< Mapspeaker[*it].m_score[index] <<Endl; } return 0;};voidMain () {//design of the containermap<int, speaker> Mapspeaker;//contestants in the competitionvector<int> v1;//List of the 1th Round speech contestvector<int> v2;//List of the 2nd Round Speech Contestvector<int> v3;//List of the 3rd Round Speech Contestvector<int> v4;//List of the last top three speech contests//the player gets the first-round match list.Genspeaker (Mapspeaker, v1); //The 1th round of contestants competition to view the results of the competitioncout <<"\n\n\n any key to start the 1th round of the game"<<Endl; Cin.Get(); Speech_contest_draw (v1); Speech_contest (0, v1, Mapspeaker, v2); Speech_contest_print (0, V2, mapspeaker); //The 2nd round of contestants competition to view the results of the competitioncout <<"\n\n\n any key to start the 2nd round of the game"<<Endl; Cin.Get(); Speech_contest_draw (v2); Speech_contest (1, V2, Mapspeaker, V3); Speech_contest_print (1, V3, mapspeaker); //The 3rd round of contestants competition to view the results of the competitioncout <<"\n\n\n any key to start the 3rd round of the game"<<Endl; Cin.Get(); Speech_contest_draw (v3); Speech_contest (2, v3, Mapspeaker, v4); Speech_contest_print (2, V4, mapspeaker); cout<<"Hello ..."<<Endl; System ("Pause"); return ;}
STL Case Study