数据结构课设预习报告

目录

一、问题定义及问题分析

二、概要设计

【数据结构设计】

【算法选择】

三、附录(源代码)


一、问题定义及问题分析

  本次课程设计要求设计一款赛事管理系统,实现计算设计大赛赛务相关的数据管理及信息服务,该系统能够为省级赛事管理解决以下问题:

(1)能够管理各参赛队的基本信息(包含参赛队编号,参赛作品名称,参赛学校,赛事类别,参赛者,指导老师),赛事类别共11项(参见大赛官网jsjds.blcu.edu.cn);包括增加、删除、修改参赛队伍的信息

(2)从team.txt中读取参赛队伍的基本信息,实现基于二叉排序树的查找。根据提示输入参赛队编号,若查找成功,输出该赛事类别对应的基本信息(参赛作品名称、参赛学校、赛事类别、参赛者和指导老师信息),同时,输出查找成功时的平均查找长度ASL;否则,输出“查找失败!”。
(3)能够提供按参赛学校查询参赛团队(或根据赛事类别查询参赛团队),即,根据提示输入参赛学校名称(赛事类别),若查找成功,输出该学校参赛的(该赛事类别的)所有团队的基本信息,输出的参赛团队按赛事类别有序输出。(排序算法可从选择排序、插入排序、希尔排序、归并排序、堆排序中任意选择,并为选择算法的原因做出说明。)

(4)为省赛现场设计一个决赛叫号系统。所有参赛队按赛事组织文件中的赛事类别分到9个决赛室,决赛室按顺序叫号,被叫号参赛队进场,比赛结束后,下一参赛队才能进赛场。请模拟决赛叫号系统,演示省赛现场各决赛室的参赛队进场情况。(模拟时,要能直观展示叫号顺序与进场秩序一致)

(5)赛事系统为参赛者提供赛地的校园导游程序,为参赛者提供各种路径导航的查询服务。以我校长山校区提供比赛场地为例,(请为参赛者提供不少于10个目标地的导航。可为参赛者提供校园地图中任意目标地(建筑物)相关信息的查询;提供任意两个目标地(建筑物)的导航查询,即查询任意两个目的地(建筑物)之间的一条最短路径。

【设计要求】

1)赛事数据要求存入文件(txt或excel)并能读入查询;

2)赛地目的地查询,需提供目的地(建筑物)名称、代号、简介、两地之间路径长度等信息;

3)输入数据形式和范围:赛事相关数据可从键盘输入,或自文件导入。

4)界面要求:交互设计要合理,每个功能可以设计菜单,用户根据提示,完成相关功能的要求。

【实现步骤提示】

1)分析任务,进行模块划分。

2)定义数据结构,建议按照抽象数据类型的定义、表示和实现来描述,用类C语言(伪代码)来描述数据的存储表示和相应操作的具体实现过程。

3)设计合适的算法来实现其功能,并绘制函数调用关系图。

二、概要设计

【数据结构设计】

ADT team
Data:

字符串表示参赛队编号;
字符串表示参赛作品名称;
字符串表示参赛学校名称;
字符串表示赛事类别;
字符串表示参赛者名称;
字符串表示指导教师名称;
endADT

ADT Operation
Data
一个存放所有team的动态数组

Operation
void addTeam

前提条件:无
输入:操作台输入
功能:增加参赛队伍
输出:增加成功
后置条件:无

void alterTeam

前提条件:无
输入:控制台输入参赛队编号
功能:修改参赛队伍

输出:修改成功
后置条件:无

void findByID
前提条件:无
输入:操作台输入参赛队编号
功能:基于二叉排序树查询某一队伍的基本参赛信息
输出:基本参赛信息(参赛作品名称、参赛学校、赛事类别、参赛者和指导老师信息)同时输出成功时的ASL平均查找长度。


void findBySchool
前提条件:无
输入:控制台输入参赛学校名称
功能:查询参赛团队
输出:输出所有该校参赛队伍的基本参赛信息且输出的参赛团队排序按赛事类别有序输出
后置条件:无
选取的排序算法是归并排序,因为思路简单,速度仅次于快速排序,为稳定排序算法。

void QueuingSystem
前提条件:九个队列分别放九个决赛室的进场队伍
输入:无
功能:模拟叫号系统
输出:按照进场顺序输出被叫到号的参赛队伍编号且输出的参赛团队按赛事类别每隔0.5s有序输出(分为九个决赛室)
后置条件:无
endADT

 

  二叉树的构造和插入操作具体实现:

struct BSTNode {
	Team team;
	BSTNode* left;
	BSTNode* right;
};
//全局根节点
BSTNode* root;
//生成新的一棵二叉排序树
BSTNode* CreateTreeNode(Team &team) {
	BSTNode* temp = new BSTNode();
	temp->team.id = team.id; temp->team.submission = team.submission; temp->team.school = team.school;
	temp->team.kind = team.kind; temp->team.competitor= team.competitor; temp->team.instruct = team.instruct;
	temp->left = NULL;
	temp->right = NULL;
	return temp;
}
//插入到二叉排序树中
BSTNode* Insert(BSTNode* root, Team &thisTeam) {
	if (root == NULL) {
		root = CreateTreeNode(thisTeam);
		return root;
	}
	if (thisTeam.id < root->team.id) {//左子树
		root->left = Insert(root->left, thisTeam);
	}
	if (thisTeam.id > root->team.id) {//右子树
		root->right = Insert(root->right, thisTeam);
	}
	return root;
}


校园导航:
选择图这一数据结构,利用C++中的结构体,实现功能。实际上就是对图的操作,包括图的表示方法(所采用的是邻接矩阵)。
选择的是Floyd算法(弗洛伊德算法)求最短路径所以需要两个用来存放记录数据的二维数组:
int PathMatirx[MAX][MAX];//记录对应点的最小路径的前驱
int distance[MAX][MAX];//记录顶点间的最小路径值

【算法选择】

  选择的是非递归式查找,而ASL的求解参考学习了网上的递归求法,具体实现如下:

BSTNode* Search(BSTNode* root, string id) {
	BSTNode* temp = root;
	while (temp != NULL && temp->team.id != id) {
		if (id< temp->team.id)
			temp = temp->left;
		else
			temp = temp->right;
	}
	return temp;
}
//查找成功的平均查找长度为:∑(本层高度*本层元素个数)/节点总数(以下三个函数全是为求ASL)
int BSTasl(BSTNode* node,int power){ //总权值(最开始已加上根节点的1,然后从整个左子树最末端开始递归加)
	power++;
	int temp = power;
	if (node->left)
		power += BSTasl(node->left, temp);
	if (node->right)
		power += BSTasl(node->right, temp);
	return power;
}
int BSTcnt(BSTNode* node){ //节点计数(也是从根节点开始加整个左子树),和即节点总数
	int sum = 0;
	if (node == NULL) { return 0;}//这行是调试后增加的,加个检验条件可以有效避免因为空指针导致的访问权限冲突异常
	sum = 1+BSTcnt(node->left) + BSTcnt(node->right);
	return sum;
}
void ASL(BSTNode* root){
	if (root==NULL) { cout << "该二叉树不存在\n"<<endl; return ; }
	cout << "该二叉排序树ASL值为:∑(本层高度*本层元素个数)/节点总数=" << BSTasl(root, 0) * 1.0 / BSTcnt(root) << endl;
}

  几大排序中选择了归并排序,最主要还是因为思路简单且速度仅次于快速排序,又考虑到在场景下要根据赛事类别排序的话还是选择稳定的排序算法更好。

  叫号系统借助九个队列实现起来较为简单。

  校园导航中选择的是Floyd算法(弗洛伊德算法)来求最短路径,因为清晰简单,可以给出网络中任意两个节点之间的最短路径。

三、附录(源代码)

#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<fstream>
#include<sstream>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
#include <iomanip>//setw
#include <windows.h>

using namespace std;
//globle variable
#define MAXVEX 12     //最大顶点个数 
#define NONE 99999
#define INFINITY 3276//图的矩阵中A(i,i)记为0,若没有通路,记为INFINITY = 32762
int PathMatirx[MAXVEX][MAXVEX];
int ShortPath[MAXVEX][MAXVEX];
int bianhao[MAXVEX];
//结点的结构体--代表实际中的景点
struct Vertex{
	int Num;
	string name;       
	string info;   
};
//邻接矩阵
struct MGraph{
	int AdjMatrix[MAXVEX][MAXVEX]; //用二维数组来存放邻接矩阵 
	Vertex vex[MAXVEX];    //顶点信息
	int vexnum;		//顶点个数
	int arcnum;     //边个数
};
struct Team {
	string id;//编号
	string submission;//作品名称
	string school;//学校名称
	string kind;//赛事类别
	string competitor;//参赛者名称
	string instruct;//指导教师名称
};
vector<Team>team;
struct BSTNode {
	Team team;
	BSTNode* left;
	BSTNode* right;
};
//全局根节点
BSTNode* root;
//初始化新的一个二叉排序树节点
BSTNode* CreateTreeNode(Team &team) {
	BSTNode* temp = new BSTNode();
	temp->team.id = team.id; temp->team.submission = team.submission; temp->team.school = team.school;
	temp->team.kind = team.kind; temp->team.competitor= team.competitor; temp->team.instruct = team.instruct;
	temp->left = NULL;
	temp->right = NULL;
	return temp;
}
//插入到二叉排序树中
BSTNode* Insert(BSTNode* root, Team &thisTeam) {
	if (root == NULL) {
		root = CreateTreeNode(thisTeam);
		return root;
	}
	if (thisTeam.id < root->team.id) {//左子树
		root->left = Insert(root->left, thisTeam);
	}
	if (thisTeam.id > root->team.id) {//右子树
		root->right = Insert(root->right, thisTeam);
	}
	return root;
}
//非递归式的查找
BSTNode* Search(BSTNode* root, string id) {
	BSTNode* temp = root;
	while (temp != NULL && temp->team.id != id) {
		if (id< temp->team.id)
			temp = temp->left;
		else
			temp = temp->right;
	}
	return temp;
}
//查找成功的平均查找长度为:∑(本层高度*本层元素个数)/节点总数(以下三个函数全是为求ASL)
int BSTasl(BSTNode* node,int power){ //总权值(最开始已加上根节点的1,然后从整个左子树最末端开始递归加)
	power++;
	int temp = power;
	if (node->left)
		power += BSTasl(node->left, temp);
	if (node->right)
		power += BSTasl(node->right, temp);
	return power;
}
int BSTcnt(BSTNode* node){ //节点计数(也是从根节点开始加整个左子树),和即节点总数
	int sum = 0;
	if (node == NULL) { return 0;}
	sum = 1+BSTcnt(node->left) + BSTcnt(node->right);
	return sum;
}
void ASL(BSTNode* root){
	if (root==NULL) { cout << "该二叉树不存在\n"<<endl; return ; }
	cout << "该二叉排序树ASL值为:∑(本层高度*本层元素个数)/节点总数=" << BSTasl(root, 0) * 1.0 / BSTcnt(root) << endl;
}
//初始化图(以下几个函数全为地图导航系统)
void InitGraph(MGraph& G) {
	int i = 0, j = 0;
	G.vexnum = 12;
	G.arcnum = 17;
	for (int i = 0; i < 12; i++) {
		G.vex[i].Num = i + 1;//第1号景点到第12号景点
	}
	G.vex[0].name = "行政楼";
	G.vex[0].info = "为学术研究员和大学行政管理人员提供一个现代化的工作空间";
	G.vex[1].name = "计算机学院楼";
	G.vex[1].info = "有很多计算机实验室";
	G.vex[2].name = "图书馆";
	G.vex[2].info = "借书阅读和自习的地方";
	G.vex[3].name = "文理大楼";
	G.vex[3].info = "江科大最高的一栋楼";
	G.vex[4].name = "东苑食堂";
	G.vex[4].info = "欢迎就餐";
	G.vex[5].name = "明德楼";
	G.vex[5].info = "很适合自习,操场对面,学累了可以去散步";
	G.vex[6].name = "西操场";
	G.vex[6].info = "下午可以踢足球";
	G.vex[7].name = "文体中心";
	G.vex[7].info = "有羽毛球馆,篮球馆等等";
	G.vex[8].name = "东操场";
	G.vex[8].info = "可以傍晚散步和夜跑";
	G.vex[9].name = "笃学楼";
	G.vex[9].info = "教学楼";
	G.vex[10].name = "西苑食堂";
	G.vex[10].info = "欢迎就餐";
	G.vex[11].name = "校医院";
	G.vex[11].info = "如果你感觉到身体不适,请到这来";
	//注意无向图是对称的
	for (int i = 0; i < 12; i++) {
		for (int j = 0; j < 12; j++) {
			G.AdjMatrix[i][j] = INFINITY;
			G.AdjMatrix[0][1] = G.AdjMatrix[1][0] = 500;
			G.AdjMatrix[0][2] = G.AdjMatrix[2][0] = 200;
			G.AdjMatrix[1][3] = G.AdjMatrix[3][1] = 250;
			G.AdjMatrix[1][9] = G.AdjMatrix[9][1] = 500;
			G.AdjMatrix[2][9] = G.AdjMatrix[9][2] = 300;
			G.AdjMatrix[2][4] = G.AdjMatrix[4][2] = 400;
			G.AdjMatrix[3][5] = G.AdjMatrix[5][3] = 350;
			G.AdjMatrix[3][9] = G.AdjMatrix[9][3] = 500;
			G.AdjMatrix[4][9] = G.AdjMatrix[9][4] = 400;
			G.AdjMatrix[4][8] = G.AdjMatrix[8][4] = 600;
			G.AdjMatrix[5][6] = G.AdjMatrix[6][5] = 250;
			G.AdjMatrix[5][10] = G.AdjMatrix[10][5] = 500;
			G.AdjMatrix[6][10] = G.AdjMatrix[10][6] = 500;
			G.AdjMatrix[6][11] = G.AdjMatrix[11][6] = 600;
			G.AdjMatrix[6][7] = G.AdjMatrix[7][6] = 400;
			G.AdjMatrix[7][9] = G.AdjMatrix[9][7] = 600;
			G.AdjMatrix[7][11] = G.AdjMatrix[11][7] = 1000;
			G.AdjMatrix[8][9] = G.AdjMatrix[9][8] = 600;
			G.AdjMatrix[10][11] = G.AdjMatrix[11][10] = 500;
		}
	}
	for (int i = 0; i < 12; i++) {
		bianhao[i] = i + 1;
	}
}
//使用Windows自带的画板打开校园平面图
void MapDisplay() {
	system("江科大地图.jpg");
}
//导游菜单
void Menu() {
	system("cls");//清屏
	cout << endl;
	cout << "|---------------------------欢迎来到校园导游菜单!------------------------------\n";
	cout << "|*******************************************************************************\n";
	cout << "|      1.显示江苏科技大学平面图               2. 校园景点一览                   \n";
	cout << "|      3.显示任意两个景点间的最短路径         0.退出                            \n";
	cout << "|*******************************************************************************\n";
	cout << endl;
}
//输出所有景点基本信息
void PrintAllInfo(MGraph& G) {
	cout.setf(ios::left, ios::adjustfield);
	cout << setw(10) << "编号" << setw(15) << "名称" << "简介" << endl;
	for (int i = 0; i < G.vexnum; i++) {
		cout << setw(10) << G.vex[i].Num << setw(15) << G.vex[i].name << G.vex[i].info << endl;
	}
}
//利用floyd算法求最短路径
void Floyd(MGraph& G) {
	//对Floyd的两个数组进行初始化
	for (int i = 0; i < G.vexnum; i++) {
		for (int j = 0; j < G.vexnum; j++) {
			PathMatirx[i][j] = j;
			ShortPath[i][j] = G.AdjMatrix[i][j];
		}
	}
	for (int k = 0; k < G.vexnum; k++) {
		for (int v = 0; v < G.vexnum; v++) {
			for (int w = 0; w < G.vexnum; w++) {
				if (ShortPath[v][w] > ShortPath[v][k] + ShortPath[k][w]) {
					//更新最短路径
					ShortPath[v][w] = ShortPath[v][k] + ShortPath[k][w];
					//更新路径中介节点
					PathMatirx[v][w] = PathMatirx[v][k];
				}
			}
		}
	}
}
void ShortestPathOfAnyTwo(MGraph& G) {
	int start, end, k;
	bool flag1 = false;
	bool flag2 = false;
	cout << "请输入要查询最短路径的两个不同的景点的编号!" << endl;
	cout << "请输入起点景点的编号:";
	cin >> start;
	cout << "请输入终点景点的编号:";
	cin >> end;
	if (start == end) {
		cout << "对不起!起点和终点的编号一样,请重新输入" << endl;
	}
	for (int i = 0; i < G.vexnum; i++) {
		if (start == G.vex[i].Num) {
			flag1 = true;
		}
		if (end == G.vex[i].Num) {
			flag2 = true;
		}
	}
	if (!(flag1 == true && flag2 == true)) {
		cout << "您输入的两个景点中有不存在的情况,请重新输入" << endl;
	}
	cout << "从景点 " << G.vex[start - 1].name << " 到景点 " << G.vex[end - 1].name << "的最短路径长度为:" << ShortPath[start][end] << endl;
	cout << "具体路径为:" << endl;
	k = PathMatirx[start][end];
	cout << start << "--->";
	while (k != end) {
		cout << k << "--->";
		k = PathMatirx[k][end];
	}
	cout << end << endl;
}
//删除字符串首位空格
string removeSpace(string word) {
	string newWord;
	for (int i = 0; i < word.length(); i++) {
		if (word[i] != '\t') {
			newWord += word[i];
		}
	}
	return newWord;
}
//从文件中读取数据
void readFromFile() {
	fstream file;
	string input;
	file.open("team.txt");
	if (file.bad()){
		cout << "AnError has happend on opening the file"; return;
	}
	else {
		while (getline(file, input)) {
			stringstream ss(input);
			string s;
			Team temp;
			int i = 0;
			while (getline(ss, s, '#')) {//按“#”隔开字符串
				s = removeSpace(s);//去除“        ”
				if (i == 0) { temp.id = s; }//插入二叉排序树中
				else if (i == 1) { temp.submission = s; }
				else if (i == 2) { temp.school = s;}
				else if (i == 3) { temp.kind = s; }
				else if (i == 4) { temp.competitor = s;}
				else if (i == 5) { temp.instruct = s; }
				i++;
			}
			root=Insert(root, temp);
			team.push_back(temp);
		}
	}
	file.close();
}
//保存数据到文件中
void saveToFile() {
	ofstream file("team.txt");
	if (!file) {
		cout << "无法找到对应文件 team.txt!" << endl;
		return;
	}
	for (const auto& team : team) {
		file << team.id << "#" << team.submission << "#" << team.school << "#"
			<< team.kind << "#" << team.competitor << "#" << team.instruct << endl;
	}
	file.close();
}
//归并排序(思路简单,速度仅次于快速排序,为稳定排序算法)
void mergeSort(vector<Team>& nums, int l, int r) {
	// 终止条件
	if (l >= r) return;
	// 递归划分
	int m = (l + r) / 2;
	mergeSort(nums, l, m); 
	mergeSort(nums, m + 1, r);
	// 合并阶段
	vector<Team>tmp;
	tmp.resize(r - l + 1); // 暂存需合并区间元素
	for (int k = l; k <= r; k++)
		tmp[k - l] = nums[k];//即将数组nums 闭区间[l, r] 内的元素存放至辅助数组tmp
	int i = 0, j = m-l + 1;       // 两指针分别指向左/右子数组的首个元素
	for (int k = l; k <= r; k++) {  // 遍历合并左/右子数组
		if (i == m - l + 1)
			nums[k] = tmp[j++];
		else if (j == r - l + 1 || tmp[i].kind <= tmp[j].kind)
			nums[k] = tmp[i++];
		else {
			nums[k] = tmp[j++];
		}
	}
}

//1.增加参赛队(增删改并保存都是要求1)
void addTeam() {
	string teamID;
	cout << "请输入您想要增加的参赛队编号:" << endl;
	cin >> teamID;
	Team temp;
	for (auto it = team.begin(); it != team.end(); ++it) {
		if (it->id == teamID) {
			cout << "添加失败!该参赛队已存在。" << endl;
			return ;
		}
	}
	temp.id = teamID;
	cout << "请依次输入所添加的参赛队其作品名称,所属学校,赛事类别,参赛者名称和指导教师名称:" << endl;
	cin >> temp.submission >> temp.school >> temp.kind
		>> temp.competitor >> temp.instruct;
	team.push_back(temp);
	cout << "添加成功!" << endl;
}
//2.修改参赛队基本信息
void alterTeam() {
	string teamID;
	cout << "请输入您想要进行调整的参赛队编号:" << endl;
	cin >> teamID;
	for(auto it = team.begin(); it != team.end(); ++it) {
		if (it->id == teamID) {
			cout << "请输入修改后的完整参赛队信息(参赛队编号,作品名称,所属学校,赛事类别,参赛者名称和指导教师名称):" << endl;
			cin >> it->id >> it->submission >> it->school >> it->kind
				>> it->competitor >> it->instruct;
			cout << "修改成功!" << endl;
			return ;
		}
	}
	cout << "抱歉,未找到该参赛队!(请检查是否输错编号)" << endl;
}
//3.删除参赛队
void deleteTeam() {
	string teamID;
	cout << "请输入所要删除的参赛队的编号:";
	cin >> teamID;
	for (auto it = team.begin(); it != team.end(); ++it) {
		if (teamID==it->id) {
			team.erase(it);//删除所指向的数据元素
			cout << "参赛队伍删除成功!" << endl;
			return;
		}
	}
	cout << "抱歉,未找到您要删除的参赛队伍!(请检查是否输错编号)" << endl;
}
//4.实现基于二叉排序树根据编号查找(要求2)
void findByID() {
	string ID;
	cout << "请输入您要查找的参赛队编号:" << endl;
	cin >> ID;
	BSTNode* it = Search(root, ID);//it存储当前所查找的参赛队编号所在的叶结点位置
	if (it == NULL) { cout << "查找失败!该参赛队编号不存在!" << endl; return; }
	cout << "查找成功!\n"
		<< "该参赛队编号为:" << it->team.id << "  参赛作品名:" << it->team.submission
		<< "\n参赛学校:" << it->team.school << "  赛事类别:" << it->team.kind
		<< "  参赛者:" << it->team.competitor << "  指导老师:" << it->team.instruct << endl;
	ASL(root);//所求是平均查找长度所以是root而不是该节点it
}
//5.根据参赛学校查询参赛队伍基本信息(要求3)
void findBySchool() {
	vector<Team>school;//临时数组,存放同一参赛学校的参赛队
	string teamsch;
	cout << "请输入您想要查询的参赛学校名:" << endl;
	cin >> teamsch;
	Team tmp;//临时对象,用来存储某一参赛队基本信息
	for (auto it = team.begin(); it != team.end(); ++it) {
		if (it->school == teamsch) {
			tmp.id = it->id; tmp.submission = it->submission; tmp.school = it->school;
			tmp.kind = it->kind; tmp.competitor = it->competitor;tmp.instruct=it->instruct;
			school.push_back(tmp);
		}
	}
	if (school.empty()) { cout << "查找失败!该参赛队不存在!" << endl; return; }
	mergeSort(school, 0, school.size() - 1);
	cout << "查找成功!\n" << "该校共有" << school.size() << "支队伍:" << endl;
	for (auto it = school.begin(); it != school.end(); ++it) { //输出基本信息
		cout<< "参赛队编号:" << it->id << "  参赛作品名:" << it->submission
			<< "  参赛学校:" << it->school << "\n赛事类别:" << it->kind
			<< "  参赛者:" << it->competitor << "  指导老师:" << it->instruct << endl<<endl;
	}
}
//6.模拟决赛叫号系统(要求4)
void QueuingSystem() {
	Team tmp;//临时变量
	queue<Team>room1; queue<Team>room2; queue<Team>room3;
	queue<Team>room4; queue<Team>room5; queue<Team>room6;
	queue<Team>room7; queue<Team>room8; queue<Team>room9;//决赛室
	for (auto it = team.begin(); it != team.end(); ++it) {//参照计设官网分类11项,同时按team.txt文件的顺序进场
		if (it->kind == "Web应用与开发" || it->kind == "管理信息系统" || it->kind == "移动应用开发" || it->kind == "移动应用开发(非游戏类)" || it->kind == "算法设计与应用"||it->kind=="信创软件应用与开发"||it->kind=="区块链应用与开发") {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind; 
			room1.push(tmp);
			continue;
		}
		if (it->kind == "计算机基础与应用类课程微课" || it->kind == "虚拟实验平台"||it->kind=="汉语言文学" || it->kind == "中、小学数学或自然科学课程微课") {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room2.push(tmp);
			continue;
		}
		if (it->kind == "城市管理" || it->kind == "医药卫生" || it->kind == "运动健身" || it->kind == "数字生活"|| it->kind == "行业应用" || it->kind == "物联网专项") {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room3.push(tmp);
			continue;
		}
		if (it->kind == "大数据实践"||it->kind=="大数据主题") {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room4.push(tmp);
			continue;
		}
		if (it->kind == "人工智能实践赛" || it->kind == "人工智能挑战赛" ) {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room5.push(tmp);
			continue;
		}
		if (it->kind == "信息图形设计" || it->kind == "动态信息影像(MG动画)" || it->kind == "交互信息设计" || it->kind == "数据可视化") {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room6.push(tmp);
			continue;
		}
		if (it->kind == "平面设计" || it->kind == "环境设计" || it->kind == "产品设计" ) {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room7.push(tmp);
			continue;
		}
		if (it->kind == "微电影" || it->kind == "数字短片" || it->kind == "纪录片" || it->kind == "动画"||it->kind == "新媒体漫画") {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room8.push(tmp);
			continue;
		}
		if (it->kind == "游戏设计" || it->kind == "交互媒体设计" || it->kind == "虚拟现实VR与增强现实AR" ) {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room9.push(tmp);
			continue;
		}
		if (it->kind == "音乐") {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room1.push(tmp);
			continue;
		}
		if (it->kind == "软件应用与开发" || it->kind == "微课与教学辅助" || it->kind == "物联网应用" || it->kind == "大数据应用"|| it->kind == "人工智能应用"|| it->kind == "信息可视化") {
			tmp.id = it->id; tmp.submission = it->submission; tmp.kind = it->kind;
			room2.push(tmp);
		}
	}
	//开始叫号:
	while(!room1.empty()|| !room2.empty() || !room3.empty() || !room4.empty() || !room5.empty() || !room6.empty() || !room7.empty() || !room8.empty() || !room9.empty() ){
		Sleep(500);
		cout << "*******************决赛赛事公屏*******************" << endl;
		if (!room1.empty()) {  cout << " 请" << room1.front().id << " 队(" << room1.front().submission << ")进场,到决赛室1比赛" << endl; room1.pop(); }
		if (!room2.empty()) {  cout << " 请" << room2.front().id << " 队(" << room2.front().submission << ")进场,到决赛室2比赛" << endl; room2.pop(); }
		if (!room3.empty()) {  cout << " 请" << room3.front().id << " 队(" << room3.front().submission << ")进场,到决赛室3比赛" << endl; room3.pop(); }
		if (!room4.empty()) { cout << " 请" << room4.front().id << " 队(" << room4.front().submission << ")进场,到决赛室4比赛" << endl; room4.pop(); }
		if (!room5.empty()) {  cout << " 请" << room5.front().id << " 队(" << room5.front().submission << ")进场,到决赛室5比赛" << endl; room5.pop(); }
		if (!room6.empty()) { cout << " 请" << room6.front().id << " 队(" << room6.front().submission << ")进场,到决赛室6比赛" << endl; room6.pop(); }
		if (!room7.empty()) {  cout << " 请" << room7.front().id << " 队(" << room7.front().submission << ")进场,到决赛室7比赛" << endl; room7.pop(); }
		if (!room8.empty()) { cout << " 请" << room8.front().id << " 队(" << room8.front().submission << ")进场,到决赛室8比赛" << endl; room8.pop(); }
		if (!room9.empty()) {  cout << " 请" << room9.front().id << " 队(" << room9.front().submission << ")进场,到决赛室9比赛" << endl; room9.pop(); }
		cout << endl<<endl;

	}
}

void showMenu(){
	cout << endl;
	cout << "         *********************************************" << endl;
	cout << "         **                                         **" << endl;
	cout << "         **  欢迎使用计算机设计大赛赛事管理系统     **" << endl;
	cout << "         **                                         **" << endl;
	cout << "         *********************************************" << endl;
	cout << endl;
	cout << "         **********************Menu*******************" << endl;
	cout << "         1. 增加参赛队伍" << endl;
	cout << "         2. 修改参赛队伍" << endl;
	cout << "         3. 删除参赛队伍" << endl;
	cout << "         4. 根据参赛队编号查询参赛队伍基本信息" << endl;
	cout << "         5. 根据参赛学校查询参赛队伍基本信息" << endl;
	cout << "         6. 决赛叫号系统" << endl;
	cout << "         7. 校园导游程序" << endl;
	cout << "         0. 退出系统" << endl;
	cout << "         *********************************************\n\n" ;
}
bool askContinue() {
	char ans;
	cout << "是否还要继续使用本系统?y/n" << endl;
	cin >> ans;
	if (ans == 'y' || ans == 'Y') return true;
	else {
		cout << "感谢您的使用!" << endl; 
		return false;
	}
}
int main() {
	root = NULL;
	readFromFile();
	int choice;
	MGraph G;
	InitGraph(G);//初始化
	bool flag = true,flag2 = true;
	while (flag){
		showMenu();
		cout << "        请输入您的选择:";
		cin >> choice;
		switch (choice){
		case 1://增加参赛队伍
			addTeam();
			saveToFile();
			flag=askContinue();
			break;
		case 2://修改参赛队伍
			alterTeam();
			saveToFile();
			flag = askContinue();
			break;
		case 3://删除参赛队伍
			deleteTeam();
			saveToFile();
			flag = askContinue();
			break;
		case 4://根据参赛队编号查询参赛队伍基本信息
			findByID();
			flag = askContinue();
			break;
		case 5:	//根据参赛学校查询参赛队伍基本信息
			findBySchool();
			flag = askContinue();
			break;
		case 6:	//决赛叫号系统
			QueuingSystem();
			flag = askContinue();
			break;
		case 7:	//校园导游程序
			Menu();
			while (flag2) {
				cout << "请输入您的选择:" << endl;
				int ans;
				cin >> ans;
				switch (ans) {
				case 1:
					MapDisplay();
					break;
				case 2:
					PrintAllInfo(G);
					break;
				case 3:
					Floyd(G);
					ShortestPathOfAnyTwo(G);
					break;
				case 0:
					cout << "感谢您的使用!" << endl;
					flag2 = false;
					break;
				default:
					cout << "您的输入有误,请重新输入" << endl;
				};
			}
			flag = askContinue();
			break;
		case 0://退出系统
			cout << "感谢使用!再见!" << endl;
			flag = false;
			break;
		default:
			cout << "非法输入!(默认退出)请重新打开该系统!" << endl;
			flag = false;
			break;
		}
	}
	return 0;
}

感谢阅读!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值