欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C++演講比賽管理系統(tǒng)實(shí)現(xiàn)流程實(shí)例

 更新時(shí)間:2022年10月25日 09:03:44   作者:彼此沉默  
這篇文章主要介紹了C++演講比賽管理系統(tǒng)實(shí)現(xiàn)流程,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧

演講比賽系統(tǒng)

1.需求分析

  • 學(xué)校舉行一場比賽,共有12人參加。比賽共兩輪,第一輪為淘汰賽,第二輪為決賽。
  • 每名選手都有對應(yīng)的編號(hào):如10001~10012。
  • 比賽方式:分組比賽,每組6個(gè)人。
  • 第一輪分為兩個(gè)小組,整體按照選手的編號(hào)進(jìn)行抽簽后順序演講。
  • 十個(gè)評委分別給每名選手打分,去除最高分和最低分,求的平均分為本輪選手的成績。
  • 當(dāng)小組演講完后,淘汰組內(nèi)排名最后的三名選手,前三名晉級,進(jìn)入下一輪的比賽。
  • 第二輪為決賽,前三名勝出。
  • 每輪比賽過后需要顯示晉級選手的信息。

2.程序和功能

程序功能
開始演講比賽完成整屆比賽的流程,每個(gè)比賽階段需要給用戶一個(gè)提示,用戶按任意鍵進(jìn)入下一個(gè)階段。
查看往屆記錄查看之前比賽的前三名,每次比賽都會(huì)記錄到文件中,文件用.csv后綴名保存。
清空比賽記錄將文件中的數(shù)據(jù)清空。
退出比賽程序可以退出程序。

3.程序邏輯

3.1建立演講比賽管理類

	void SaveRecord();
	//初始化
	void InitSpeech();
	//判斷文件是否為空
	bool File_Is_Empty;
	//往屆數(shù)據(jù)的容器
	map<int, vector<string>>M_Record;
	~Speech_Manager();
	void CreatSpeaker();
	string CreatName(int a);
	void ShowScore();
	void Wait_Revolution();
	//往屆記錄
	void ShowRecord();
	//清空記錄
	void ClearRecord();
	//讀取記錄
	void LoadRecod();
	//創(chuàng)建輪數(shù)
	int Revolution;
	//第一輪比賽人員編號(hào)
	vector<int>v1;
	//第二輪比賽人數(shù)編號(hào)
	vector<int>v2;
	//獲勝人編號(hào)
	vector<int>vVictory;
	//存放編號(hào)和對應(yīng)具體選手的容器
	map<int, Speaker>M_Speker;
	//存放屆數(shù)
};

3.2開始演講比賽程序

比賽流程分析:

抽簽—>開始第一輪演講比賽—>顯示第一輪比賽結(jié)果—>抽簽—>開始第二論比賽—>

顯示前三名結(jié)果—>保存分?jǐn)?shù)。

void Speech_Manager::SpeechConst()
{
	/*srand((unsigned int)time(NULL));*/
	cout << "----------------第" << this->Revolution << "輪比賽開始-----------------" << endl;
	multimap<double, int, greater<double>>GroupScore;
	int num = 0;
	vector<int>V_src;//參賽容器
	if (this->Revolution == 1)
	{
		V_src = v1;
	}
	else
	{
		V_src = v2;
	}
	//遍歷選手
	for (vector<int>::iterator it = V_src.begin(); it != V_src.end(); it++)
	{
		num++;
		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_front();
			d.pop_back();
			double sum = accumulate(d.begin(), d.end(), 0.0f);
			double average = sum / (double)d.size();//平均分
			//將平均分放入到map容器當(dāng)中
			this->M_Speker[*it].M_Score[this->Revolution - 1] = average;
			GroupScore.insert(make_pair(average, *it));
			if (num % 6 == 0)
			{
				cout << "第" << num / 6 << "小組比賽名次如下:" << endl;
				for (multimap<double, int, greater<double>>::iterator it = GroupScore.begin(); it != GroupScore.end(); it++)
				{
					cout << "編號(hào):" << it->second << "姓名:" << this->M_Speker[it->second].M_Name
						<< "成績:" << this->M_Speker[it->second].M_Score[this->Revolution - 1] << endl;
				}
				int count = 0;
				for (multimap<double, int, greater<double>>::iterator it = GroupScore.begin(); it != GroupScore.end()&&count<3; it++,count++)
				{
					if (this->Revolution == 1)
					{
						v2.push_back((*it).second);
					}
					else
					{
						vVictory.push_back((*it).second);
					}
				}
				GroupScore.clear();
				cout << endl;
			}
		}
		cout << "-------------第" << this->Revolution << "輪比賽結(jié)束-------------" << endl;
	system("pause");
}
void Speech_Manager::ShowScore()
{
	cout << "-------------第" << this->Revolution << "輪晉級選手信息如下:----------" << endl;
	vector<int>v;
	if (this->Revolution == 1)
	{
		v = v2;
	}
	else
	{
		v = vVictory;
	}
	for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
	{
		cout << "選手編號(hào):" << *it << "性別:" << this->M_Speker[*it].M_Sex << "姓名:" << this->M_Speker[*it].M_Name
			<< "得分:" << this->M_Speker[*it].M_Score[this->Revolution - 1] << endl;
	}
	cout << endl;
	system("pause");
	system("cls");
	this->ShowmMenu();
}

3.3查看往屆比賽結(jié)果程序

void Speech_Manager::ShowRecord()
{
	if (this->File_Is_Empty)
	{
		cout << "顯示失??!文件為空或者不存在!";
	}
	else
	{ 
		for (int i = 0; i < this->M_Record.size(); i++)
		{
			//cout << this->M_Record.size();
			cout << "第" << i + 1 << "屆比賽結(jié)果如下:" << endl;
			cout << "冠軍編號(hào):" << this->M_Record[i][0] << "\t"<<"   姓名:" << this->M_Record[i][1] 
				<< "\t" <<"性別:" <<this->M_Record[i][2] << "\t" <<"得分:"<< this->M_Record[i][3] <<endl;
			cout << "亞軍編號(hào):" << this->M_Record[i][4] << "\t" << "   姓名:" << this->M_Record[i][5]
				<< "\t" << "性別:" << this->M_Record[i][6] << "\t" << "得分:" << this->M_Record[i][7] << endl;
			cout << "季軍編號(hào):" << this->M_Record[i][8] << "\t" << "   姓名:" << this->M_Record[i][9]
				<< "\t" << "性別:" << this->M_Record[i][10] << "\t" << "得分:" << this->M_Record[i][11] << endl;
		}
	}
	system("pause");
	system("cls");
}

3.4清空記錄

void Speech_Manager::ClearRecord()
{
	cout << "是否清空文件記錄" << endl;
	cout << "1.確定" << endl;
	cout << "2.否認(rèn)" << endl;
	int select = 0;
	cin >> select;
	if (select == 1)
	{
		//確認(rèn)清空
		ofstream ofs("File_Name.txt",ios::trunc);
		ofs.close();
		this->InitSpeech();
		this->CreatSpeaker();
		//加載往屆記錄
		this->LoadRecod();
		cout << "清空成功" << endl;
	}
	system("pause");
	system("cls");
	}

3.5等待程序和隨機(jī)產(chǎn)生姓名程序

oid Speech_Manager::Wait_Revolution()
{
	for (int i = 0; i < 3; i++)
{
	cout << "Wait ";
	for (int j = 0; j < 3; j++)
	{
		Sleep(1500);
		cout << " * ";
	}
	system("cls");
	cout << "正在抽簽,請等待" << endl;
}
}
string Speech_Manager::CreatName(int a)//a隨機(jī)次數(shù),a不同導(dǎo)致不同結(jié)果。
{
	string name;
	string NA1[] = { "趙", "錢", "孫", "李", "周", "吳", "鄭", "王", "馮", "陳", "褚", "衛(wèi)", "蔣" };
	string NA2[] = { "偉", "剛", "勇", "毅", "俊", "峰","秀", "娟", "英", "華", "慧" };
	srand((unsigned int)(time)(NULL));
	for (int i = 0; i < a; i++)
	{
		name = NA1[rand() % (sizeof(NA1) / sizeof(NA1[0]))];
		name += NA2[rand() % (sizeof(NA2) / sizeof(NA2[0]))];
	}
	return name;
}

4.程序下載

鏈接: https://pan.baidu.com/s/1f-43Ne9MWCU1kYstJfU5Xg?pwd=nswe

提取碼: nswe 

到此這篇關(guān)于C++演講比賽管理系統(tǒng)實(shí)現(xiàn)流程實(shí)例的文章就介紹到這了,更多相關(guān)C++演講比賽管理內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論