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

如何做网站流量买卖如何快速推广网上国网

如何做网站流量买卖,如何快速推广网上国网,建设网站必须要服务器吗,做的网站访问不了该案例是黑马的案例&#xff0c;不方便下载源代码的可以看一下 该案例有两个头文件&#xff0c;两个源文件 main.c &#xff1a;与用户交互 &#xff0c;显示菜单等 #include<iostream> using namespace std; #include"speechManager.h" #include<ctime&…

该案例是黑马的案例,不方便下载源代码的可以看一下

该案例有两个头文件,两个源文件

main.c :与用户交互 ,显示菜单等

#include<iostream>
using namespace std;
#include"speechManager.h"
#include<ctime>
int main()
{srand((unsigned int)time(NULL));SpeechManager sm;//创建speechmanager对象for (auto it = sm.m.begin(); it != sm.m.end(); it++){cout << "编号:" << it->first << "   姓名:" << it->second.m_name << "   分数:" << it->second.m_score[0] << endl;}while (1){sm.showMeneu();cout << "请选择:" << endl;int chooce;cin >> chooce;switch (chooce){case 1:sm.startspeech();//开始比赛break;case 2:sm.showrecord();//比赛记录break;case 3:sm.clearecord();//清除记录break;case 0:sm.exitsystem();//退出程序break;default:system("cls");break;}}system("pause");return 0;
}

speaker.h  :里面存放speeker类

#pragma once
#include<iostream>
using namespace std;
#include<string>class Speaker
{
public:string m_name;double m_score[2];//最多有两轮得分
};

speechmanager.h : 存放功能函数的声明,以及speaker的容器

第一轮演讲12人,用v1存储

第二轮6人,用v2存储

胜出的3人,用win存储

#pragma
#include<iostream>
#include<vector>
#include<map>
#include"speaker.h"
#include<algorithm>
#include<numeric>
#include<string>
#include<fstream>
using namespace std;
class SpeechManager
{
public:SpeechManager();//菜单void showMeneu();//退出void exitsystem();//容器初始化void initspeech();//创建选手void creatspeaker();~SpeechManager();//开始比赛void startspeech();//抽签void speechdraw();//比赛进程void speechcontest();//显示得分void showscore();//保存分数void saverecord();//读取记录void loadrecord();//显示往届记录void showrecord();//判断文件是否为空bool fileempty;//存放往届记录的容器map<int, vector<string>>m_record;//清空记录void clearecord();vector<int>v1;vector<int>v2;vector<int>win;map<int, Speaker>m;int m_index;
};

speechmanager.c :功能函数的实现

#include<iostream>
using namespace std;
#include"speechManager.h"
#include<deque>
#include<algorithm>
SpeechManager::SpeechManager()
{this->initspeech();this->creatspeaker();\//加载往届记录this->loadrecord();
}void SpeechManager::showMeneu()
{cout << "******************************" << endl;cout << "********欢迎参加演讲比赛******" << endl;cout << "********1、开始演讲比赛*******" << endl;cout << "********2、查看往届记录*******" << endl;cout << "********3、清空比赛记录*******" << endl;cout << "********0、退出比赛程序*******" << endl;cout << "******************************" << endl;
}	void SpeechManager::exitsystem()
{cout << "欢迎下次使用" << endl;system("pause");exit(0);
}
void SpeechManager::initspeech()
{//容器置空this->v1.clear();this->v2.clear();this->win.clear();this->m.clear();this->m_index = 1;this->m_record.clear();
}
//创建选手
void SpeechManager::creatspeaker()
{string nameseed = "ABCDEFGHIJKL";for (int i = 0; i < nameseed.size(); i++){string name = "选手";name += nameseed[i];Speaker sp;sp.m_name = name;for (int i = 0; i < 2; i++){sp.m_score[i] = 0;}this->v1.push_back(i+10001);this->m.insert(make_pair(i + 10001, sp));}
}
//开始比赛
void SpeechManager::startspeech()
{//第一轮开始比赛//抽签this->speechdraw();//比赛this->speechcontest();//显示结果this->showscore();//第二轮开始比赛this->m_index++;//抽签this->speechdraw();//比赛this->speechcontest();//显示结果this->showscore();//保存记录this->saverecord();this->initspeech();this->creatspeaker();this->loadrecord();cout << "比赛完毕。" << endl;system("pause");system("cls");
}
void SpeechManager::speechdraw()
{cout << "第<<" << this->m_index << ">>轮比赛选手正在抽签" << endl;cout << "————————————" << endl;cout << "抽签后演讲顺序如下: " << endl;if (this->m_index == 1){ random_shuffle(v1.begin(), v1.end());for (auto it = v1.begin(); it != v1.end(); it ++ ){cout << *it << " ";}}else{random_shuffle(v2.begin(), v2.end());for (auto it = v2.begin(); it != v2.end(); it ++ ){cout << *it << " ";}}cout << "————————————" << endl;system("pause");cout << endl;
}
void SpeechManager::speechcontest()
{cout << "————————第<<" << this->m_index << ">>轮比赛开始————————" << endl;//临时容器存放成绩multimap<double, int, greater<double>>group;int num = 0;vector<int>v_scr;if (this->m_index == 1){v_scr = v1;}else{v_scr = v2;}for (auto it = v_scr.begin(); it != v_scr.end(); it++){num++;deque<double>d;for (int i = 0; i < 10; i++){double score = (rand() % 401 + 600)/10.f;//cout << score << " ";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);//平均分double avr = sum / (double)d.size();//cout << "编号:" <<*it<< "   姓名:"<<this->m[*it].m_name<<"   平均分:"<<avr<<endl;//平均分放入mapthis->m[*it].m_score[this->m_index - 1] = avr;//分数放入临时容器group.insert(make_pair(avr, *it));//key是平均分  val是编号if (num % 6 == 0){cout << "第<<" << num / 6 << ">>小组比赛名次:" << endl;for (auto it = group.begin(); it != group.end(); it++){cout << "编号:" << it->second << "   姓名:" << this->m[it->second].m_name << "   成绩:" << it->first << endl;}//取前三int count = 0;for (auto it=group.begin();it!=group.end()&&count<3;it++,count++){if (this->m_index==1){v2.push_back((*it).second);}else{win.push_back((*it).second);}}group.clear();cout << endl;}}cout << "————————第<<" << this->m_index<< ">>轮比赛完毕————————" << endl;system("pause");}
//显示得分
void SpeechManager::showscore()
{cout << "——————第<<" << this->m_index << ">>轮晋级选手信息如下——————" << endl;vector<int>v;if (this->m_index == 1){v = v2;}else{v = win;}for (auto it = v.begin(); it!= v.end(); it++){cout << "编号:" << *it << "   姓名:"<< this->m[*it].m_name << "   成绩:" << this->m[*it].m_score[this->m_index-1] << endl;}cout << endl;system("pause");system("cls");this->showMeneu();
}
void SpeechManager::saverecord()
{ofstream ofs;ofs.open("speech.csv", ios::out | ios::app);for (auto it = win.begin(); it != win.end(); it++){ofs << *it << "," << this->m[*it].m_score[1] << ",";}ofs << endl;ofs.close();cout << "记录已保存" << endl;this->fileempty = false;}
void SpeechManager::loadrecord()
{ifstream ifs("speech.csv", ios::in);if (!ifs.is_open()){this->fileempty = true;//cout << "文件不存在。" << endl;ifs.close();return;}	char ch;ifs >> ch;if (ifs.eof()){//cout << "文件为空。" << endl;this->fileempty = true;ifs.close();return;}this->fileempty = false;ifs.putback(ch);string data;int index = 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);//cout << temp << endl;v.push_back(temp);start = pos + 1; }this->m_record.insert(make_pair(index, v));index++;}ifs.close();for (auto it = this->m_record.begin(); it != this->m_record.end(); it++){cout << it->first << " 冠军编号: " << it->second[0] << "分数: " << it->second[1] << endl;}}void SpeechManager::showrecord()
{if (this->fileempty){cout << "文件为空或不存在"<<endl;}else {for (int i = 0; i < this->m_record.size(); i++){cout << "第<<" << i + 1 << ">>届" << endl<< " 冠军编号: " << this->m_record[i][0] << "分数: " << this->m_record[i][1] << endl<< " 亚军编号: " << this->m_record[i][2] << "分数: " << this->m_record[i][3] << endl<< " 季军编号: " << this->m_record[i][4] << "分数: " << this->m_record[i][5] << endl;}}
}
void SpeechManager::clearecord()
{cout << "是否确认清空?" << endl;cout << "1、是" << endl << "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");
}
SpeechManager::~SpeechManager()
{}

http://www.dtcms.com/wzjs/193956.html

相关文章:

  • 郑州网站建设喝彩杭州小周seo
  • 网站主页的布局方式哪个公司要做网络推广
  • 怎么做网站的支付功能测试渠道网官网
  • 东营网站建设专业定制千锋培训学费多少钱
  • 中小企业做网站推广口碑营销的优势有哪些
  • 2016年做网站能赚钱舆情监测软件免费版
  • 三网合一网站建设程序最近国际新闻大事
  • dba网站网络营销公司全网推广公司
  • html手机网站怎么做酒店如何进行网络营销
  • 做网站用什么语言好每日新闻简报
  • 班级网站源代码大众网潍坊疫情
  • pc做网站服务器友链外链app
  • 自己做的网站能干站什么营销技巧和营销方法培训
  • 南阳政府做网站推广吗整站关键词快速排名
  • 加强网站微信公众号平台建设高清的网站制作
  • 广州网络公司建站国内最新新闻
  • 中文单页面网站模板免费下载建站流程新手搭建网站第一步
  • 网站栏目排序宣传推广方式有哪些
  • 湘潭做网站价格优选磐石网络外贸推广方式
  • 兰州的互联网公司广州seo团队
  • 高端互联网网站百度云网盘登录入口
  • 著名的淘宝客网站互联网推广员是做什么的
  • 外包公司做网站怎么样最新的域名网站
  • 深圳福田网站建设公司搜索引擎网站入口
  • 网站开发软件公司网络营销企业是什么
  • 遂宁商城网站建设方案软文范例大全300字
  • bootstrap网站模板下载公司网站建设平台
  • 河北秦皇岛建设局网站桂林网站设计制作
  • 望江县建设局网站推广引流网站
  • 做app做网站从何学起2021年重大新闻事件