当前位置: 首页 > news >正文

长治网站建设WordPress站群更新

长治网站建设,WordPress站群更新,五金企业网站模板,网站后台页面设计任务 学校演讲比赛#xff0c;12人#xff0c;两轮#xff0c;第一轮淘汰赛#xff0c;第二轮决赛 选手编号 [ 10001 - 10012 ] 分组比赛 每组6人 10个评委 去除最高分 最低分#xff0c;求平均分 为该轮成绩 每组淘汰后三名#xff0c;前三名晋级决赛 决赛 前三名胜出 … 任务 学校演讲比赛12人两轮第一轮淘汰赛第二轮决赛 选手编号 [ 10001 - 10012 ] 分组比赛 每组6人 10个评委 去除最高分 最低分求平均分 为该轮成绩 每组淘汰后三名前三名晋级决赛 决赛 前三名胜出 每轮 比赛过后 要显示晋级选手信息 点击此处-下载源代码 功能 开始演讲比赛完成 一整届比赛流程每阶段给用户提示任意键进入下一阶段查看往届记录查看比赛前三名结果每次比赛都记录到文件中用*.csv存储清空记录将文件中数据清空退出程序将文件中数据清空 效果图 speechManager.h #pragma once #include iostream #include vector #include map #include algorithm #include deque #include functional #include numeric #include fstream #includespeaker.h using namespace std; /*1.提供惨淡界面与用户交互2.对演讲比赛流程进行控制3.与文件读写交互 */ class SpeechManager { public:vectorint v1; //比赛选手 12人 第一轮vectorint v2; //第一轮晋级 6人vectorint vVectory; //晋级 3人mapint, Speaker m_Speaker;//编号具体选手 map容器int m_Index; //比赛轮数mapint, vectorstring m_Record; //存放往届记录bool fileIsEmpty; //file是否为空SpeechManager();void show_Menu();void initSpeech(); //初始化容器属性void createSpeaker(); //创建12名选手void exit_Sys_0();void speechDraw(); //抽签void speechContest(); //竞赛void showScore(); //显示得分void saveRecord(); //Save 记录void startSpeech_1(); //开始整个流程void loadRecode(); //读取往届记录void showRecode_2(); //查看记录void clearRecode_3();~SpeechManager(); };class printVectorInt{ public:void operator()(int val) {cout val ; ;} };speaker.h #pragma once #include iostream using namespace std;class Speaker { public:void setSpeakerName(string name);void setSpeakerS1(double a);void setSpeakerS2(double a);string getName();double* getScore();private:string m_Name;double* m_Score new double[2]; //两轮得分数组 }; SpeechCompetition_Sys.cpp #includeiostream #includestring #include ctime #includespeechManager.h #includespeaker.husing namespace std;int main() {srand((unsigned int)time(NULL));SpeechManager sm; //test://for (mapint, Speaker::iterator it sm.m_Speaker.begin(); it ! sm.m_Speaker.end(); it) {// double* arr it-second.getScore();// cout Test ID: it-first// \t Name: it-second.getName()// \t Score: arr[0] endl;//}int inputChoice -1;while (1) {sm.show_Menu();cout Please input Your Choice : endl;cin inputChoice;switch (inputChoice) {case 1: //开始比赛sm.startSpeech_1();break;case 2: //往届记录sm.showRecode_2();break;case 3: //清空记录sm.clearRecode_3();break;case 0: //退出sm.exit_Sys_0();break;default:system(cls);break;}}system(pause);return 0; }speaker.cpp #includespeaker.h #includestring using namespace std;void Speaker::setSpeakerName(string name) {this-m_Name name; }void Speaker::setSpeakerS1(double a) {this-m_Score[0] a; }void Speaker::setSpeakerS2(double a) {this-m_Score[1] a; }string Speaker::getName() {return m_Name; } double* Speaker::getScore() {return this-m_Score; /*Speaker s;string name GodOuO;double score[2] { 12,34.5 };s.setSpeaker(name, score);double* arr s.getScore();cout arr[0] arr[1];delete[] arr; */ } speechManager.cpp #includespeechManager.hSpeechManager::SpeechManager() {this-initSpeech(); //初始化容器属性this-createSpeaker(); //创建12名选手this-loadRecode(); //加载数据 }void SpeechManager::show_Menu() {cout ******************************* endl *****SpeechCompetition_Sys***** endl **********#1.Start ********** endl **********#2.Histry ********** endl **********#3.Clean ********** endl **********#0.Quit ********** endl endl; }void SpeechManager::exit_Sys_0() {cout Bye Bye !!! endl;system(pause);exit(0); }void SpeechManager::initSpeech() {//容器置空this-v1.clear();this-v2.clear();this-vVectory.clear();this-m_Speaker.clear();//index置空this-m_Index 1;this-m_Speaker.clear(); }void SpeechManager::createSpeaker() {string nameSpace ABCDEFGHIJKL;for (int i 0; i nameSpace.length(); i){string name Name;name nameSpace[i];Speaker s;s.setSpeakerName(name);s.setSpeakerS1(0.0);s.setSpeakerS2(0.0);this-v1.push_back(i 10001); //选手编号 存入v1this-m_Speaker.insert(make_pair(i 10001, s));//选手编号 和对应选手 存入map} }void SpeechManager::speechDraw() {cout The No.( this-m_Index ) Rounds Player is Drawing... endl ----------------------------------------------------- endl The Order is : endl;if (1 this-m_Index) { //Round 1random_shuffle(v1.begin(),v1.end());for_each(v1.begin(), v1.end(), printVectorInt());}else if (2 this-m_Index) { //Round 2random_shuffle(v2.begin(), v2.end());for_each(v2.begin(), v2.end(), printVectorInt());}cout endl ----------------------------------------------------- endl;system(pause);cout endl; }void SpeechManager::speechContest() {cout The No.( this-m_Index ) Rounds Contest is Fighting... endl ----------------------------------------------------- endl;vectorint v_Player; //比赛选手容器multimapdouble, int, greaterdouble groupScore; //准备临时容器存放小组成绩int num 0; //记录人员个数 6人一组if (1 this-m_Index) {v_Player this-v1;}else if (2 this-m_Index) {v_Player this-v2;}for (vectorint::iterator it v_Player.begin(); it ! v_Player.end(); it){ //遍历所有选手dequedouble d; //评委打分num; //统计人数for (int i 0; i 10; i){double score (rand() % 401 600) / 10.f; //(600-1000) /10.f//test:// coutTest:endl;//cout score ; ;d.push_back(score);}//cout endl;sort(d.begin(), d.end(), greaterdouble()); //倒叙排序d.pop_front(); //del Topd.pop_back(); //del Lastdouble sum accumulate(d.begin(), d.end(), 0.0f); //起始累加值 0.0f小数double avg sum / (double)d.size(); //平均分if (1 m_Index)this-m_Speaker[*it].setSpeakerS1(avg); //平均分 存入 map容器else if(2 m_Index)this-m_Speaker[*it].setSpeakerS2(avg); //平均分 存入 map容器groupScore.insert(make_pair(avg, *it)); //key 平均成绩value IDif (0 num % 6) { //每六个人 取前三cout No. num / 6 group‘s Contest List: endl ----------------------------------------------------- endl;for (multimapdouble,int,greaterdouble::iterator it groupScore.begin(); it ! groupScore.end(); it){double* arr this-m_Speaker[it-second].getScore();cout ID: it-second \tName: this-m_Speaker[it-second].getName() \tScore: arr[this-m_Index - 1]endl;}//取走前三int count 0;for (multimapdouble, int, greaterdouble::iterator it groupScore.begin(); it ! groupScore.end() count 3; it,count){if (1 this-m_Index)this-v2.push_back((*it).second);else this-vVectory.push_back((*it).second);}groupScore.clear(); //del 缓存 组成绩cout endl;}/*cout Test: endl;double* arr this-m_Speaker[*it].getScore();cout ID: *it \tName: this-m_Speaker[*it].getName() \tScore: arr[0];*/} cout No.( this-m_Index ) group‘s Contest Done!!! endl;system(pause);cout endl; }void SpeechManager::showScore() {cout The No.( this-m_Index ) Rounds Winner List: endl ----------------------------------------------------- endl;vectorint v;if (1 this-m_Index){v v2;}else if (2 this-m_Index) {v vVectory;}for (vectorint::iterator it v.begin(); it! v.end(); it){double* arr this-m_Speaker[*it].getScore();cout ID: *it \tName: this-m_Speaker[*it].getName() \tScore: arr[this-m_Index - 1] endl;}cout endl;system(pause);system(cls);this-show_Menu(); }void SpeechManager::saveRecord() {ofstream ofs;ofs.open(speech.csv,ios::out | ios::app); //追加 写入for (vectorint::iterator it vVectory.begin(); it ! vVectory.end(); it) //数据写入文件{double* arr this-m_Speaker[*it].getScore(); //冠亚季三人ofs *it , arr[1] ,;}ofs endl;ofs.close();this-fileIsEmpty false;cout Save it!!! endl; }void SpeechManager::startSpeech_1(){//第一轮比赛1.抽签2.比赛3.显示结果this-speechDraw();this-speechContest();this-showScore();//第二轮比赛1.抽签2.比赛3.显示结果m_Index;this-speechDraw();this-speechContest();this-showScore();//保存分数到文件this-saveRecord();//重置比赛获取记录this-initSpeech(); //初始化容器属性this-createSpeaker(); //创建12名选手this-loadRecode(); //加载数据cout endl This Round is Finished!!! endl;system(pause);system(cls); }void SpeechManager::showRecode_2() {if (this-fileIsEmpty){cout File is Empty!!! endl;}else {for (int i 0; i this-m_Record.size(); i){cout NO.( i 1 ) Round Champions ID: this-m_Record[i][0] \tScore: this-m_Record[i][1] endl;cout NO.( i 1 ) Round No.2s ID: this-m_Record[i][2] \tScore: this-m_Record[i][3] endl;cout NO.( i 1 ) Round No.3s ID: this-m_Record[i][4] \tScore: this-m_Record[i][5] endl;}}system(pause);system(cls); }void SpeechManager::loadRecode() {ifstream ifs(speech.csv, ios::in);if (!ifs.is_open()) //文件不存在{this-fileIsEmpty true;//cout File is NOT Exist !!! endl;ifs.close();return;}//文件清空char c;ifs c;if (ifs.eof()) {this-fileIsEmpty true;//cout File is Empty !!! endl;ifs.close();return;}this-fileIsEmpty false;ifs.putback(c); //将上文读取单个字符 存回string data; int index 0; //第几届while (ifs data) {//test://cout data endl;int loc -1; //查到’‘ locint start 0;vectorstring vtemp; //存放 6个 string 字符串while (1){loc data.find(,, start);if (-1 loc) { //未找到 ’‘break;}string temp data.substr(start, loc - start);//test://cout temp endl;vtemp.push_back(temp);start loc 1;}this-m_Record.insert(make_pair(index, vtemp));index;}ifs.close();// test:// for (mapint,vectorstring::iterator it this-m_Record.begin(); it ! this-m_Record.end() ; it)//{// cout it-first// Winner ID: it-second[0]// \tScore: it-second[1] endl;//}}void SpeechManager::clearRecode_3(){cout endl Sure ? endl 1.Yes endl 2.No endl;int select 0;cin select;if (1 select) {//ios::trunc 如果文件存在删除文件 重新创建ofstream ofs(speech.csv, ios::trunc);ofs.close();//初始化this-initSpeech(); //初始化容器属性this-createSpeaker(); //创建12名选手this-loadRecode(); //加载数据cout Clean Done! endl;}system(pause);system(cls); }SpeechManager::~SpeechManager() { }
http://www.w-s-a.com/news/952793/

相关文章:

  • 招商加盟网站系统站长工具 seo查询
  • 工商局网站清算组备案怎么做电商培训机构
  • 做好门户网站建设做本地团购网站怎么样
  • wordpress主题和预览不同20条优化防疫措施方案
  • 艾奇视觉网站建设网站推广需要几个人做
  • 2008 iis 添加网站wordpress固定链接标签加上页面
  • 宁波企业网站制作推荐网站优化人员
  • 大型资讯门户网站怎么做排名沈阳建设工程有限公司
  • 开发中英文切换网站如何做江苏网站建设费用
  • 网站论文首页布局技巧桥东网站建设
  • 网站开发项目经理工资北京微信网站
  • 山西山西省建设厅网站微信备份如何转换为wordpress
  • 同城网站开发实用网站模板
  • 郑州做网站哪家公司好国外购买空间的网站有哪些
  • 资讯cms网站有那些餐饮品牌策划设计公司
  • 网站策划选题网站布局优化
  • 网站建设3000字wordpress 微信 主题制作
  • 代做寄生虫网站网站菜单效果
  • 网站备案为什么这么慢目录更新 wordpress
  • 视频在线制作网站Wordpress 外链图片6
  • 网站域名后缀有什么用网站建设的投资预算怎么写
  • 化妆品网站建设网站惠州网站关键字优化
  • 保定网站制作企业下载天眼查企业查询官网
  • 中山企业网站建设公司制作一个景点的网站
  • 连云港集团网站建设株洲建设网站
  • 做运动鞋评价的网站南山做网站联系电话
  • 网站开发公众号开发海南做公司网站
  • 论企业网站建设的必要性微信小程序做一个多少钱
  • 网站制作价格是多少元上海市中小企业服务中心
  • 网站建设管理人员济宁网站建设top