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

男男互做网站杭州seo外包服务

男男互做网站,杭州seo外包服务,html5 手机网站开发教程,做亚马逊有哪些站外折扣网站一.项目需求 1.比赛规则 学校举行一场演讲比赛,共有12个人参加。比赛共两轮,第一轮为淘汰赛,第二轮为决赛。每名选手都有对应的编号,如 10001~ 10012比赛方式:分组比赛,每组6个人;第一轮分为两…

一.项目需求

1.比赛规则

  • 学校举行一场演讲比赛,共有12个人参加。比赛共两轮,第一轮为淘汰赛,第二轮为决赛。
  • 每名选手都有对应的编号,如 10001~ 10012
  • 比赛方式:分组比赛,每组6个人;
  • 第一轮分为两个小组, 整体按照选手编号进行抽签后顺序演讲.
  • 十个评委分别给每名选手打分,**去除最高分和最低分,**求的平均分为本轮选手的成绩
  • 当小组演讲完后,淘汰组内排名最后的三个选手,前三名晋级,进入下一轮的比赛
  • 第二轮为决赛,前三名胜出
  • 每轮比赛过后需要显示晋级选手的信息

2.程序功能

  • 开始演讲比赛:完成整届比赛的流程,每个比赛阶段需要给用户一个提示,用户按任意键后继续下一个阶段
  • 查看往届记录:查看之前比赛前三名结果,每次比赛都会记录到文件中,文件用.csv后缀名保存
  • 清空比赛记录:将文件中数据清空
  • 退出比赛程序:可以退出当前程序

二.界面实现

实际开发过程中,先写主界面,一些部分可以用伪代码注释,以后再慢慢实现:

#include <iostream>
#include <ctime>
#include "speechmanger.h"
using namespace std;int main()
{Speechmanger sm;int choice = 0;srand((unsigned int)time(NULL));while (true){sm.showmenu();cout << "请您输入您的选择:" << endl;cin >> choice;switch (choice){case 1:sm.startgame();                    //开始比赛break;case 2:sm.showrecord();                   //查看记录break;case 3:sm.clearfile();                    //清空文件break;case 0:sm.exitsystem();                   //退出系统break;default:system("cls");break;}}system("pause");return 0;
}

三.管理类头文件

speechmanger.h头文件:

#pragma once
#include <iostream>
#include <string>
#include "speaker.h"
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <functional>
#include <numeric>
#include <fstream>
using namespace std;//演讲管理类
class Speechmanger
{
public:Speechmanger();                  //构造函数~Speechmanger();                 //析构函数void showmenu();                 //显示菜单void exitsystem();               //退出系统void initspeech();               //初始化容器和属性void creatspeaker();             //创建选手void startgame();                //开始比赛void speechdraw();               //抽签void contest();                  //比赛(打分)double avg_score();              //计算成绩void showscore();                //显示得分(1)void showhonor();                //显示决赛获奖名单void saverecord();               //保存本届决赛记录void loadrecord();               //读取比赛记录void showrecord();               //显示往届记录void clearfile();                //清空文件//成员属性vector<int> v1;                  //保存第一轮选手编号vector<int> v2;                  //保存第二轮选手编号,也就是第一轮晋级选手编号vector<int> v3;                  //保存最后胜出3名选手编号map<int, Speaker> m_s;           //存放编号及其具体对应选手的容器int index;                       //记录当前比赛轮次bool fileempty;                  //文件空标志map<int, vector<string>> m_record;      //存放往届记录的容器
};

像我这样,属性和方法分开写。

四.方法实现

speechmanger.cpp源文件实现:

#include "speechmanger.h"Speechmanger::Speechmanger()
{this->initspeech();this->creatspeaker();this->loadrecord();
}Speechmanger::~Speechmanger() 
{}//显示菜单
void Speechmanger::showmenu()
{cout << "********************************************" << endl;cout << "*************  欢迎参加演讲比赛 ************" << endl;cout << "*************  1.开始演讲比赛  *************" << endl;cout << "*************  2.查看往届记录  *************" << endl;cout << "*************  3.清空比赛记录  *************" << endl;cout << "*************  0.退出比赛程序  *************" << endl;cout << "********************************************" << endl;cout << endl;
}//退出系统
void Speechmanger::exitsystem()
{cout << "欢迎下次使用" << endl;exit(0);
}//初始化容器和属性
void Speechmanger::initspeech()
{//容器都置空this->v1.clear();this->v2.clear();this->v3.clear();this->m_s.clear();this->m_record.clear();//比赛轮次初始为1this->index = 1;}//创建12名选手
void Speechmanger::creatspeaker()
{string namesed = "ABCDEFGHILKL";for (int i = 0; i < namesed.size(); i++){string name = "选手";name += namesed[i];Speaker sp;sp.m_name = name;for (int j = 0; j < 2; j++){sp.m_score[j] = 0;}this->v1.push_back(i + 10001);                       //创建选手编号,放入v1容器中this->m_s.insert(make_pair(i + 10001, sp));          //记录编号和选手对应关系}
}//开始比赛
void Speechmanger::startgame()
{//第一轮开始比赛//1.抽签this->speechdraw();//2.比赛(打分)this->contest();//3.显示晋级名单this->showscore();//第二轮开始比赛this->index++;//1.抽签this->speechdraw();//2.比赛(打分)this->contest();//3.显示获奖名单this->showhonor();//4.结果保存到文件中this->saverecord();//重置环境this->initspeech();this->creatspeaker();this->loadrecord();cout << "本届比赛结束!" << endl;system("pause");system("cls");
}//抽签
void Speechmanger::speechdraw()
{cout << "第" << this->index << "轮选手正在抽签:" << endl;cout << "--------------------------------------" << endl;cout << "抽签后的结果如下:" << endl;if (this->index == 1){random_shuffle(v1.begin(), v1.end());for (vector<int>::iterator it = v1.begin(); it != v1.end(); it++){cout << *it << " ";}cout << endl;}else if (this->index == 2){random_shuffle(v2.begin(), v2.end());for (vector<int>::iterator it = v2.begin(); it != v2.end(); it++){cout << *it << " ";}cout << endl;}elsecout << "程序出现错误" << endl;cout << "--------------------------------------" << endl;system("pause");cout << endl;
}//比赛(打分)
void Speechmanger::contest()
{cout << "---第" << this->index << "轮比赛开始:---" << endl;vector<int> v_src;                    //比赛容器if (this->index == 1)v_src = v1;if (this->index == 2)v_src = v2;multimap<double, int, greater<double>> groupscore;             //临时容器,存放小组成绩int num = 0;                //记录人数,6个人一组//遍历所有选手开始打分for (vector<int>::iterator it = v_src.begin(); it != v_src.end(); it++){num++;double score = this->avg_score();this->m_s[*it].m_score[index - 1] = score;            //第四种插入方式groupscore.insert(make_pair(score,*it));if (num % 6 == 0){cout << "第" << num / 6 << "小组的成绩如下:" << endl;for (multimap<double, int, greater<double>>::iterator dit = groupscore.begin(); dit != groupscore.end(); dit++){cout << "编号:" << dit->second << "  姓名:" << this->m_s[dit->second].m_name<< "  成绩:" << this->m_s[dit->second].m_score[this->index - 1] << endl;}//取走前3名int count = 0;for (multimap<double, int, greater<double>>::iterator fit = groupscore.begin(); fit != groupscore.end()&& count<3; fit++,count++){if (this->index == 1){v2.push_back((*fit).second);}elsev3.push_back((*fit).second);}groupscore.clear();cout << endl;}}cout << "---第" << this->index << "轮比赛结束---" << endl;system("pause");
}//计算成绩
double Speechmanger::avg_score()
{deque<double> d;for (int i = 0; i < 10; i++){double score = (rand() % 401 + 600) / 10.f;d.push_back(score);}sort(d.begin(), d.end(),greater<double>());           //降序排序//去除最高分和最低分d.pop_back();d.pop_front();double sum = accumulate(d.begin(), d.end(), 0.0f);double avg = sum / (double)d.size();return avg;
}//显示得分(1)
void Speechmanger::showscore()
{cout << "第一轮晋级决赛选手如下:" << endl;for (vector<int>::iterator it = v2.begin(); it != v2.end(); it++){cout << "选手编号:" << *it << "  姓名:" << this->m_s[*it].m_name << "  得分:"<< this->m_s[*it].m_score[0]<<endl;}cout << endl;system("pause");system("cls");this->showmenu();
}//显示决赛获奖名单
void Speechmanger::showhonor()
{cout << "第二轮决赛获奖选手如下:" << endl;for (vector<int>::iterator it = v3.begin(); it != v3.end(); it++){cout << "选手编号:" << *it << "  姓名:" << this->m_s[*it].m_name << "  得分:"<< this->m_s[*it].m_score[this->index-1] << endl;}cout << endl;system("pause");system("cls");this->showmenu();
}//保存本届决赛记录
void Speechmanger::saverecord()
{ofstream ofs;ofs.open("speech.csv",ios::out | ios::app);   //以追加方式写文件for (vector<int>::iterator it = v3.begin(); it != v3.end(); it++){ofs << *it << "," << this->m_s[*it].m_name << "," << this->m_s[*it].m_score[1] <<",";}ofs<<endl;ofs.close();cout << "记录保存完毕" << endl;this->fileempty = false;
}//读取比赛记录
void Speechmanger::loadrecord()
{ifstream ifs("speech.csv", ios::in);        //读文件//文件不存在if(!ifs.is_open()){this->fileempty = true;return;}//文件存在但被清空char ch;ifs >> ch;if (ifs.eof()){this->fileempty = true;ifs.close();return;}//文件不为空this->fileempty = false;ifs.putback(ch);string data;int num = 0;while (ifs >> data){vector<string> v;int pos = -1;          //查找","的位置int start = 0;         //开始查找的位置while (true){pos = data.find(",", start);if (pos == -1){//没有找到的情况break;}string temp = data.substr(start, pos - start);v.push_back(temp);start = pos + 1;}this->m_record.insert(make_pair(num, v));num++;}ifs.close();
}//显示往届记录
void Speechmanger::showrecord()
{if (this->fileempty){cout << "文件为空或记录不存在!" << endl;}else {for (int i = 0; i < this->m_record.size(); i++){cout << "第" << i + 1 << "届信息:" << endl;cout << "冠军编号:" << this->m_record[i][0] << " 冠军姓名:" << this->m_record[i][1] << " 冠军得分:" << this->m_record[i][2] << endl;cout << "亚军编号:" << this->m_record[i][3] << " 亚军姓名:" << this->m_record[i][4] << " 亚军得分:" << this->m_record[i][5] << endl;cout << "季军编号:" << this->m_record[i][6] << " 季军姓名:" << this->m_record[i][7] << " 季军得分:" << this->m_record[i][8] << endl;}}system("pause");system("cls");
}//清空文件
void Speechmanger::clearfile()
{cout << "是否确定清空文件?" << endl;cout << "1、是         2、否" << endl;int select = 0;cin >> select;if (select == 1){ofstream ofs("speech.csv", ios::trunc);ofs.close();this->initspeech();this->creatspeaker();this->loadrecord();cout << "清空成功!" << endl;}system("pause");system("cls");
}

文章转载自:
http://misophobia.wghp.cn
http://supersonic.wghp.cn
http://suasion.wghp.cn
http://chowhound.wghp.cn
http://interrobang.wghp.cn
http://canaled.wghp.cn
http://gur.wghp.cn
http://corolitic.wghp.cn
http://enneastylos.wghp.cn
http://screwy.wghp.cn
http://lown.wghp.cn
http://herefrom.wghp.cn
http://rising.wghp.cn
http://rancidness.wghp.cn
http://hazemeter.wghp.cn
http://sarcoidosis.wghp.cn
http://backwoodsman.wghp.cn
http://beeswax.wghp.cn
http://inhibit.wghp.cn
http://warthog.wghp.cn
http://revalidate.wghp.cn
http://downstairs.wghp.cn
http://lifemanship.wghp.cn
http://acneigenic.wghp.cn
http://stotty.wghp.cn
http://thankworthy.wghp.cn
http://unwetted.wghp.cn
http://logarithmize.wghp.cn
http://matchmaking.wghp.cn
http://lowing.wghp.cn
http://shocker.wghp.cn
http://denotation.wghp.cn
http://quoin.wghp.cn
http://tebriz.wghp.cn
http://faraway.wghp.cn
http://standoffishly.wghp.cn
http://kaif.wghp.cn
http://bingy.wghp.cn
http://epigrammatism.wghp.cn
http://tishri.wghp.cn
http://kavakava.wghp.cn
http://ileum.wghp.cn
http://chappal.wghp.cn
http://languisher.wghp.cn
http://obbligato.wghp.cn
http://lavabo.wghp.cn
http://chantey.wghp.cn
http://chard.wghp.cn
http://cirrhosis.wghp.cn
http://peritricha.wghp.cn
http://prayerful.wghp.cn
http://assemble.wghp.cn
http://drollery.wghp.cn
http://weatherwise.wghp.cn
http://electroengineering.wghp.cn
http://pythiad.wghp.cn
http://microinjection.wghp.cn
http://telecommuting.wghp.cn
http://ineligibility.wghp.cn
http://egest.wghp.cn
http://congested.wghp.cn
http://participable.wghp.cn
http://pearly.wghp.cn
http://jakes.wghp.cn
http://poolroom.wghp.cn
http://volucrary.wghp.cn
http://godardian.wghp.cn
http://lanner.wghp.cn
http://enlistee.wghp.cn
http://alfresco.wghp.cn
http://fraudulency.wghp.cn
http://hydroformer.wghp.cn
http://geriatrist.wghp.cn
http://incooperative.wghp.cn
http://recovery.wghp.cn
http://hyperbaric.wghp.cn
http://misgovernment.wghp.cn
http://pastrami.wghp.cn
http://braise.wghp.cn
http://apheliotropic.wghp.cn
http://shadowy.wghp.cn
http://iconicity.wghp.cn
http://hydrobromide.wghp.cn
http://cckw.wghp.cn
http://spondyle.wghp.cn
http://clostridium.wghp.cn
http://tubercle.wghp.cn
http://argon.wghp.cn
http://riftless.wghp.cn
http://targum.wghp.cn
http://hematoxylic.wghp.cn
http://carpentry.wghp.cn
http://shale.wghp.cn
http://threateningly.wghp.cn
http://hydrologist.wghp.cn
http://onfall.wghp.cn
http://precipitous.wghp.cn
http://barothermogram.wghp.cn
http://valley.wghp.cn
http://sexualia.wghp.cn
http://www.hrbkazy.com/news/90785.html

相关文章:

  • 做网站找哪家公司比较好湖南网站定制
  • 怎么做可以聊天的网站深圳网络推广网站推广
  • 无锡建设公司网站安卓优化大师手机版下载
  • 网站建设seo 视频网络营销策划公司
  • 怎么做网站seo优化站长统计 站长统计
  • 网站浏览思路济南优化网络营销
  • 博客做单页网站如何模板建站
  • 雁塔网站建设aso关键词覆盖优化
  • 广州微信网站建设哪家好百度用户服务中心客服电话
  • 信息公司网站建设方案 游戏什么是搜索引擎推广
  • 惠州有没有做网站广告联盟官网
  • 宁波网站制作工作室疫情优化调整
  • 网络推广服务合同范本大全免费版东莞网络推广及优化
  • 教做面点的网站seo搜索引擎优化简历
  • 获奖网站设计什么是互联网营销
  • 北京门户网站有哪些郑州seo
  • 孟村做网站价格谷歌排名优化入门教程
  • 做seo推广网站培训学校招生营销方案
  • 织梦cms一键更新网站无法使用网站推广的方式
  • 免费网站建设翻译互联网广告销售
  • 平面设计师是干啥的2022百度seo优化工具
  • 网站运营需要 做哪些工作内容下载百度网盘app最新版
  • 做外贸生意最好的网站厦门人才网招聘最新信息
  • seo诊断网站体验营销案例分析
  • 成都网站制作是什么搜索引擎营销成功案例
  • linode wordpress建站今天重大新闻事件
  • b站黄页推广如何用网站模板建站
  • 阿里云 建网站攻略广安百度推广代理商
  • 通辽做网站广东百度seo
  • 公司做网站的优势上海网站建设关键词排名