【赛事管理系统】

赛事管理系统

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include <ctime>
#include <windows.h>
#include<chrono>
#include<iomanip>

const int Max = 999;//队伍最大值
using namespace std;
struct Team {
	int room;//决赛室
	int number;//编号
	string offering;//参赛作品名称
	string school;//参赛学校
	string category;//赛事类别
	string name;//参赛者
	string teacher;//教师
	int score;//得分
	string sta;//状态
}teams[Max];//结构体类型数量最大值Max
struct Tree {
	int number;
	Team* t;//队伍信息
	Tree* lchild, * rchild;//左右指针
};//二叉结点
struct vertex {
	int Num;//景点的编号
	string name;       //景点
	string info;    //景点信息
};//无向图
struct graph {
	int AdjMatrix[13][13]; //存放邻接矩阵 
	vertex vex[13];    //顶点信息
	int vexnum;        //顶点数 
	int arcnum;     //边数 
};
int Count = 0;//队伍数
double ASL = 0;//平均查找长度
//读取信息
Tree* root = NULL;
Tree* insertBST(Tree* root, Team* team) {
	if (root == NULL) {
		Tree* root1 = new Tree();
		root1->number = team->number;
		root1->t = team;
		root1->lchild = root1->rchild = NULL;
		return root1;
	}
	if (root->number < team->number) {
		root->rchild = insertBST(root->rchild, team);
	}
	else if (root->number > team->number) {
		root->lchild = insertBST(root->lchild, team);
	}
	return root;
}
Tree* Sreachnum(Tree* root, int number, int depth) {

	if (root == NULL)return NULL;
	if (root->number == number) {
		return root;
	}
	if (root->number < number) {
		return Sreachnum(root->rchild, number, depth + 1);
	}
	else return Sreachnum(root->lchild, number, depth + 1);
	//if (root->number != number)return NULL;
}
//计算ASL
int asl(Tree* root, int number, int depth) {
	if (root == NULL)return 0;
	if (root->number == number) {
		return depth;
	}
	if (root->number < number) {
		return asl(root->rchild, number, depth + 1);
	}
	else return asl(root->lchild, number, depth + 1);
	if (root->number != number)return 0;
}
void Read() {
	ifstream file("team.txt");
	if (!file) {
		cout << "打开文件失败" << endl;
	}
	string line;
	while (getline(file, line)) {
		Team t;
		string s;
		int index = 0;
		if (!s.empty()) {
			while ((index = s.find('\t', index)) != string::npos) {
				s.erase(index, 1);
			}
		}
		stringstream ss(line);			//实现字符串的输入,初始化ss
		getline(ss >> std::ws, s, '#');
		getline(ss >> std::ws, t.offering, '#');
		getline(ss >> std::ws, t.school, '#');
		getline(ss >> std::ws, t.category, '#');
		getline(ss >> std::ws, t.name, '#');
		getline(ss >> std::ws, t.teacher, '#');
		t.number = atoi(s.c_str());			//将编号转化为整形
		teams[Count] = t;                  //记录个数
		Count++;
	}
	for (int i = 0; i < Count - 1; i++) {		//去除首行,整体前移一位
		teams[i] = teams[i + 1];
	}
	Count--;
	for (int i = 0; i < Max; i++) {
		root = insertBST(root, &teams[i]);
	}
	file.close();
}
void writefile() {
	ofstream ofs("team.txt", ios::out);
	if (!ofs) {
		cout << "文件打开失败" << endl;
	}
	for (int i = 0; i < Count; i++)
	{
		ofs << teams[i].number << "#" << teams[i].offering << "#" << teams[i].school << "#" << teams[i].category << "#" << teams[i].name << "#" << teams[i].teacher << endl;
	}
	ofs.close();
}
//插入队伍
void Insert() {
	Team a;
	cout << "请输入添加队伍编号:";
	cin >> a.number;
	cout << "请输入添加队伍的作品名称:";
	cin >> a.offering;
	cout << "请输入添加队伍学校:";
	cin >> a.school;
	cout << "请输入添加队伍的赛事类别:";
	cin >> a.category;
	cout << "请输入添加参赛者:";
	cin >> a.name;
	cout << "请输入添加队伍指导老师:";
	cin >> a.teacher;
	teams[Count] = a;
	cout << "添加成功" << '\n';
	root = insertBST(root, &teams[Count]);
	Count++;
	writefile();
	system("pause");
	system("cls");
}
//删除队伍
void Delete() {
	int num;
	cout << "请输入要删除的队伍编号:";
	cin >> num;
	Tree* s = Sreachnum(root, num, 0);
	cout << "删除的队伍为" << s->t->offering << " " << s->t->school << " " << s->t->category << " " << s->t->name << " " << s->t->teacher << endl;
	for (int i = 0; i < Count; i++) {
		if (teams[i].number == num) {
			for (int j = i; j < Count; j++) {
				teams[j] = teams[j + 1];
			}
			Count--;
			writefile();
			root = NULL;
		    for (int i = 0; i < Max; i++) {
				root = insertBST(root, &teams[i]);
			}
			cout << "删除成功" << endl;
			system("pause");
			system("cls");
			return;
		}
	}
	cout << "不存在此队伍" << endl;
}
//更改队伍信息
void revise() {
	int num;
	cout << "输入你要修改那个队伍的信息(输入编号):";
	cin >> num;
	Tree* s = Sreachnum(root, num, 0);
	cout << "修改的原队伍为" << s->t->offering << " " << s->t->school << " " << s->t->category << " " << s->t->name << " " << s->t->teacher << endl;
	string s1, s2, s3, s4, s5;
	cout << "请输入更改后参赛作品名称:";
	cin >> s1;
	s->t->offering = s1;
	cout << "请输入更改后队伍学校:";
	cin >> s2;
	s->t->school = s2;
	cout << "请输入更改后的队伍的赛事类别:";
	cin >> s3;
	s->t->category = s3;
	cout << "请输入更改后参赛者:";
	cin >> s4;
	s->t->name = s4;
	cout << "请输入更改后队伍指导老师:";
	cin >> s5;
	s->t->teacher = s5;
	writefile();
	cout << "修改成功" << endl;
	system("pause");
	system("cls");
}
//比赛叫号
Team tea[Max];//分组总队伍
vector<Team> v1;
vector<Team> v2;
vector<Team> v3;
vector<Team> v4;
vector<Team> v5;
vector<Team> v6;
vector<Team> v7;
vector<Team> v8;
vector<Team> v9;
vector<Team> v10;
vector<Team> v11;
vector<Team> v12;
vector<Team> v13;
vector<Team> v14;
vector<Team> v15;
vector<Team> v16;
vector<Team> v17;
bool cmp(Team p1, Team p2) {
	return p1.score > p2.score;
}//仿函数
int Count1 = 0;//分组队伍数
void que() {
	string stu[3] = { "候场中","比赛中","比赛结束" };
	ifstream file("team1.txt");
	if (!file) {
		cout << "打开文件失败" << endl;
	}
	string line;
	while (getline(file, line)) {
		Team t;
		string s, sr;
		int index = 0;
		if (!s.empty()) {
			while ((index = s.find('\t', index)) != string::npos) {
				s.erase(index, 1);
			}
		}
		stringstream ss(line);			//实现字符串的输入,初始化ss
		getline(ss >> std::ws, s, '#');
		getline(ss >> std::ws, sr, '#');
		getline(ss >> std::ws, t.offering, '#');
		getline(ss >> std::ws, t.school, '#');
		getline(ss >> std::ws, t.category, '#');
		getline(ss >> std::ws, t.name, '#');
		getline(ss >> std::ws, t.teacher, '#');
		t.room = atoi(s.c_str());
		t.number = atoi(sr.c_str());		//转化为整形
		tea[Count1] = t;                  //记录个数
		Count1++;
	}
	for (int i = 0; i < Count1 - 1; i++) {
		tea[i] = tea[i + 1];
		tea[i].score = rand() % 41 + 60;
		tea[i].sta = stu[0];
	}
	Count1--;
	for (int i = 0; i < Count1; i++) {
		if (tea[i].room == 1) {
			v1.push_back(tea[i]);
			sort(v1.begin(), v1.end(), cmp);
		}
		if (tea[i].room == 2) {
			v2.push_back(tea[i]);
			sort(v2.begin(), v2.end(), cmp);
		}
		if (tea[i].room == 3) {
			v3.push_back(tea[i]);
			sort(v3.begin(), v3.end(), cmp);
		}
		if (tea[i].room == 4) {
			v4.push_back(tea[i]);
			sort(v4.begin(), v4.end(), cmp);
		}
		if (tea[i].room == 5) {
			v5.push_back(tea[i]);
			sort(v5.begin(), v5.end(), cmp);
		}
		if (tea[i].room == 6) {
			v6.push_back(tea[i]);
			sort(v6.begin(), v6.end(), cmp);
		}
		if (tea[i].room == 7) {
			v7.push_back(tea[i]);
			sort(v7.begin(), v7.end(), cmp);
		}
		if (tea[i].room == 8) {
			v8.push_back(tea[i]);
			sort(v8.begin(), v8.end(), cmp);
		}
		if (tea[i].room == 9) {
			v9.push_back(tea[i]);
			sort(v9.begin(), v9.end(), cmp);
		}
		if (tea[i].room == 10) {
			v10.push_back(tea[i]);
			sort(v10.begin(), v10.end(), cmp);
		}
		if (tea[i].room == 11) {
			v11.push_back(tea[i]);
			sort(v11.begin(), v11.end(), cmp);
		}
		if (tea[i].room == 12) {
			v12.push_back(tea[i]);
			sort(v12.begin(), v12.end(), cmp);
		}
		if (tea[i].room == 13) {
			v13.push_back(tea[i]);
			sort(v13.begin(), v13.end(), cmp);
		}
		if (tea[i].room == 14) {
			v14.push_back(tea[i]);
			sort(v14.begin(), v14.end(), cmp);
		}
		if (tea[i].room == 15) {
			v15.push_back(tea[i]);
			sort(v15.begin(), v15.end(), cmp);
		}
		if (tea[i].room == 16) {
			v16.push_back(tea[i]);
			sort(v16.begin(), v16.end(), cmp);
		}
		if (tea[i].room == 17) {
			v17.push_back(tea[i]);
			sort(v17.begin(), v17.end(), cmp);
		}
	}
}
void call() {
	string stu[3] = { "候场中","比赛中","比赛完毕" };
	cout << "输入比赛队伍赛区:";
	int a; cin >> a;
	cout << "比赛开始:" << endl;
	if (a == 1)
	{
		for (int i = 0; i < v1.size(); i++) {
			v1[i].score = rand() % 41 + 60;
			time_t currentTime = time(nullptr);
			struct tm* localTime = localtime(&currentTime);
			cout << "=====================" << put_time(localTime, "%Y-%m-%d %H:%M:%S") << "=====================" << endl;
			for (int j = 0; j < v1.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v1[j].number << "   " << "决赛得分为:" << v1[j].score << endl;
				}
				if (j == i) {
					if (i == v1.size() - 1) {
						v1[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v1[j].number << "   " << "决赛得分为:" << v1[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v1[i].number << endl;
					}
				}
				if (j > i) {
					if (j == i + 1){
						cout << "下一个上场的队伍为:" << v1[j].number << endl;
					}
					else{
						cout << "待场的队伍编号为:" << v1[j].number << endl;
					}
				}
			}
			Sleep(1000);
			cout << endl;
			v1[i].sta = stu[2];
			system("cls");
		}
		cout << "第一赛区叫号结束" << endl;
	}
	if (a == 2)
	{
		for (int i = 0; i < v2.size(); i++) {
			v2[i].score = rand() % 41 + 60;
			time_t currentTime = time(nullptr);
			struct tm* localTime = localtime(&currentTime);
			for (int j = 0; j < v2.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v2[j].number << "   " << "决赛得分为:" << v2[j].score << endl;
				}
				if (j == i) {
					if (i == v2.size() - 1) {
						v2[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v2[j].number << "   " << "决赛得分为:" << v2[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v2[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v2[j].number << endl;
				}
			}
			Sleep(1000);
			cout << endl;
			v2[i].sta = stu[2];
			system("cls");
		}
		cout << "第二赛区叫号结束" << endl;
	}
	if (a == 3) {
		for (int i = 0; i < v3.size(); i++) {
			v3[i].score = rand() % 41 + 60;
			time_t currentTime = time(nullptr);
			struct tm* localTime = localtime(&currentTime);
			for (int j = 0; j < v3.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v3[j].number << "   " << "决赛得分为:" << v3[j].score << endl;
				}
				if (j == i) {
					if (i == v3.size() - 1) {
						v3[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v3[j].number << "   " << "决赛得分为:" << v3[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v3[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v3[j].number << endl;
				}
			}
			Sleep(1000);
			cout << endl;
			v3[i].sta = stu[2];
			system("cls");
		}
		cout << "第三赛区叫号结束" << endl;
	}
	if (a == 4){
		for (int i = 0; i < v4.size(); i++) {
			v4[i].score = rand() % 41 + 60;
			for (int j = 0; j < v4.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v4[j].number << "   " << "决赛得分为:" << v4[j].score << endl;
				}
				if (j == i) {
					if (i == v4.size() - 1) {
						v4[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v4[j].number << "   " << "决赛得分为:" << v4[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v4[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v4[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v4[i].sta = stu[2];
			system("cls");
		}
		cout << "第四赛区叫号结束" << endl;

	}
	if (a == 5) {
		for (int i = 0; i < v5.size(); i++) {
			v5[i].score = rand() % 41 + 60;
			for (int j = 0; j < v5.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v5[j].number << "   " << "决赛得分为:" << v5[j].score << endl;
				}
				if (j == i) {
					if (i == v5.size() - 1) {
						v5[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v5[j].number << "   " << "决赛得分为:" << v5[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v5[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v5[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v5[i].sta = stu[2];
			system("cls");
		}
		cout << "第五赛区叫号结束" << endl;
	}
	if (a == 6) {
		for (int i = 0; i < v6.size(); i++) {
			v6[i].score = rand() % 41 + 60;
			for (int j = 0; j < v6.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v6[j].number << "   " << "决赛得分为:" << v6[j].score << endl;
				}
				if (j == i) {
					if (i == v6.size() - 1) {
						v6[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v6[j].number << "   " << "决赛得分为:" << v6[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v6[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v6[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v6[i].sta = stu[2];
			system("cls");
		}
		cout << "第六赛区叫号结束" << endl;
	}
	if (a == 7) {
		for (int i = 0; i < v7.size(); i++) {
			v7[i].score = rand() % 41 + 60;
			for (int j = 0; j < v7.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v7[j].number << "   " << "决赛得分为:" << v7[j].score << endl;
				}
				if (j == i) {
					if (i == v7.size() - 1) {
						v7[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v7[j].number << "   " << "决赛得分为:" << v7[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v7[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v7[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v7[i].sta = stu[2];
			system("cls");
		}
		cout << "第七赛区叫号结束" << endl;
	}
	if (a == 8) {
		for (int i = 0; i < v8.size(); i++) {
			v8[i].score = rand() % 41 + 60;
			for (int j = 0; j < v8.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v8[j].number << "   " << "决赛得分为:" << v8[j].score << endl;
				}
				if (j == i) {
					if (i == v8.size() - 1) {
						v8[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v8[j].number << "   " << "决赛得分为:" << v8[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v8[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v8[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v8[i].sta = stu[2];
			system("cls");
		}
		cout << "第八赛区叫号结束" << endl;
	}
	if (a == 9) {
		for (int i = 0; i < v9.size(); i++) {
			v9[i].score = rand() % 41 + 60;
			for (int j = 0; j < v9.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v9[j].number << "   " << "决赛得分为:" << v9[j].score << endl;
				}
				if (j == i) {
					if (i == v9.size() - 1) {
						v9[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v9[j].number << "   " << "决赛得分为:" << v9[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v9[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v9[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v9[i].sta = stu[2];
			system("cls");
		}
		cout << "第九赛区叫号结束" << endl;
	}
	if (a == 10) {
		for (int i = 0; i < v10.size(); i++) {
			v10[i].score = rand() % 41 + 60;
			for (int j = 0; j < v10.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v10[j].number << "   " << "决赛得分为:" << v10[j].score << endl;
				}
				if (j == i) {
					if (i == v10.size() - 1) {
						v10[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v10[j].number << "   " << "决赛得分为:" << v10[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v10[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v10[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v10[i].sta = stu[2];
			system("cls");
		}
		cout << "第十赛区叫号结束" << endl;
	}
	if (a == 11) {
		for (int i = 0; i < v11.size(); i++) {
			v11[i].score = rand() % 41 + 60;
			for (int j = 0; j < v11.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v11[j].number << "   " << "决赛得分为:" << v11[j].score << endl;
				}
				if (j == i) {
					if (i == v2.size() - 1) {
						v11[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v11[j].number << "   " << "决赛得分为:" << v11[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v11[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v11[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v11[i].sta = stu[2];
			system("cls");
		}
		cout << "第十一赛区叫号结束" << endl;
	}
	if (a == 12) {
		for (int i = 0; i < v12.size(); i++) {
			v12[i].score = rand() % 41 + 60;
			for (int j = 0; j < v12.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v12[j].number << "   " << "决赛得分为:" << v12[j].score << endl;
				}
				if (j == i) {
					if (i == v12.size() - 1) {
						v12[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v12[j].number << "   " << "决赛得分为:" << v12[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v12[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v12[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v12[i].sta = stu[2];
			system("cls");
		}
		cout << "第十二赛区叫号结束" << endl;
	}
	if (a == 13) {
		for (int i = 0; i < v13.size(); i++) {
			v13[i].score = rand() % 41 + 60;
			for (int j = 0; j < v13.size(); j++) {
				if (j < i) {
					cout << "比赛结束的队伍编号:" << v13[j].number << "   " << "决赛得分为:" << v13[j].score << endl;
				}
				if (j == i) {
					if (i == v13.size() - 1) {
						v13[j].score = rand() % 41 + 60;
						cout << "比赛结束的队伍编号:" << v13[j].number << "   " << "决赛得分为:" << v13[j].score << endl;
					}
					else {
						cout << "比赛中的队伍编号:" << v13[i].number << endl;
					}
				}
				if (j > i) {
					cout << "待场的队伍编号为:" << v13[j].number << endl;
				}
			}
			Sleep(2 * 1000);
			cout << endl;
			v13[i].sta = stu[2];
			system("cls");
		}
		cout << "第十三赛区叫号结束" << endl;
	}
	//
}
//导航
int PathMatirx[13][13];
int ShortPath[13][13];
int vertex1[13];
void initgraph(graph& G) {
	int i = 0, j = 0;
	G.vexnum = 13;
	G.arcnum = 19;
	for (int i = 0; i < 13; i++) {
		G.vex[i].Num = i+1;//第1号景点到第13号景点
	}
	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 = "53栋学生宿舍";
	G.vex[10].info = "学生晚上休息睡觉的地方";
	G.vex[11].name = "后勤服务楼";
	G.vex[11].info = "如果你生活有不便,请来这里";
	G.vex[12].name = "好又多超市";
	G.vex[12].info = "有很多新鲜水果和零食";
	for (int i = 0; i < 13; i++) {
		for (int j = 0; j < 13; j++) {
			G.AdjMatrix[i][j] = 9999;
		}
	}
	G.AdjMatrix[0][1] = G.AdjMatrix[1][0] = 12;
	G.AdjMatrix[0][2] = G.AdjMatrix[2][0] = 18;
	G.AdjMatrix[1][3] = G.AdjMatrix[3][1] = 4;
	G.AdjMatrix[1][9] = G.AdjMatrix[9][1] = 11;
	G.AdjMatrix[2][9] = G.AdjMatrix[9][2] = 12;
	G.AdjMatrix[2][4] = G.AdjMatrix[4][2] = 10;
	G.AdjMatrix[3][5] = G.AdjMatrix[5][3] = 6;
	G.AdjMatrix[3][9] = G.AdjMatrix[9][3] = 14;
	G.AdjMatrix[4][9] = G.AdjMatrix[9][4] = 9;
	G.AdjMatrix[4][8] = G.AdjMatrix[8][4] = 9;
	G.AdjMatrix[5][6] = G.AdjMatrix[6][5] = 3;
	G.AdjMatrix[5][10] = G.AdjMatrix[10][5] = 12;
	G.AdjMatrix[6][10] = G.AdjMatrix[10][6] = 13;
	G.AdjMatrix[6][7] = G.AdjMatrix[7][6] = 6;
	G.AdjMatrix[6][12] = G.AdjMatrix[12][6] = 7;
	G.AdjMatrix[7][9] = G.AdjMatrix[9][7] = 13;
	G.AdjMatrix[7][12] = G.AdjMatrix[12][7] = 22;
	G.AdjMatrix[8][9] = G.AdjMatrix[9][8] = 8;
	G.AdjMatrix[10][11] = G.AdjMatrix[11][10] = 13;
	G.AdjMatrix[10][12] = G.AdjMatrix[12][10] = 6;
	G.AdjMatrix[11][12] = G.AdjMatrix[12][11] = 20;
	for (int i = 0; i < 13; i++) {
		vertex1[i] = i ;
	}
}
void printinfo(graph G) {
	for (int i = 0; i < 13; i++)
	{
		cout <<i+1<<":"<< G.vex[i].name << " " << G.vex[i].info << endl;
	}
}
void Floyd(graph& 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 shortpath(graph& 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;
}
//目录
void menu() {
	cout << "输入想要进行什么操作" << '\n';
	cout << "1.添加队伍" << '\n';
	cout << "2.删除队伍" << '\n';
	cout << "3.修改队伍" << '\n';
	cout << "4.编号查找队伍" << '\n';
	cout << "5.决赛叫号系统" << '\n';
	cout << "6.校园导航系统" << '\n';
}
void menu1() {
	cout << "-------导航系统-------" << endl;
	cout << "1----预览景点特色" << endl;
	cout << "2----到目的地的最短距离" << endl;
	cout << "0----退出导航" << endl;
}
void menu2() {
	cout << "----------决赛叫号系统----------" << endl;
	cout << "1----------输出决赛秩序册" << endl;
	cout << "2----------决赛现场模拟" << endl;
	cout << "0----------退出模拟系统" << endl;
}
int main() {
	Read();
	while (1) {
		menu();
		int x;
		cin >> x;
		switch (x)
		{
		case 1: {
			Insert();
			break;
		}
		case 2: {
			Delete();
			break;
		}
		case 3: {
			revise();
			break;
		}
		case 4: {
			cout << "输入要查找的参赛队编号:";
			int number1;
			cin >> number1;
			Tree* s = Sreachnum(root, number1, 1);//按编号查找
			if (s != NULL) {
				cout << "参赛作品名称:" << s->t->offering << '\t' << "参赛学校:" << s->t->school
					<< '\t' << "赛事类型:" << s->t->category << '\t' << "参赛者:"
					<< s->t->name << '\t' << "指导老师:" << s->t->teacher << endl;
				double s1 = 0;
				for (int i = 0; i < Count; i++) {
					int s2;
					s2 = asl(root, teams[i].number, 1);
					s1 += s2;//查找成功所有结点查找次数 
				}
				ASL = s1 / Count;
				cout << "ASL=" << ASL << endl;
				system("pause");
				system("cls");
			}
			else cout << "查找失败!" << '\n';
			break;
		}
		case 5: {
			menu2();
			que();
			int a;
			bool f = true;
			while (f) {
				cout << "请输入你的选择--:"; cin >> a;
				switch (a)
				{
				case 1: {
					cout << "请输入要查询的比赛赛区:";
					int b; cin >> b;
					if (b == 1) {
						cout << "第一队出场顺序编号为:" << endl;
						for (int i = 0; i < v1.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v1[i].number << "初赛得分:" << v1[i].score << "状态: " << v1[i].sta << endl;
						}
					}
					if (b == 2) {
						cout << "第二队出场顺序编号为:" << endl;
						for (int i = 0; i < v2.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v2[i].number << "初赛得分:" << v2[i].score << "状态: " << v2[i].sta << endl;
						}
					}
					if (b == 3) {
						cout << "第三队出场顺序编号为:" << endl;
						for (int i = 0; i < v3.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v3[i].number << "初赛得分:" << v3[i].score << "状态: " << v3[i].sta << endl;
						}
					}
					if (b == 4) {
						cout << "第四队出场顺序编号为:" << endl;
						for (int i = 0; i < v4.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v4[i].number << "初赛得分:" << v4[i].score << "状态: " << v4[i].sta << endl;
						}
					}
					if (b == 5) {
						cout << "第五队出场顺序编号为:" << endl;
						for (int i = 0; i < v5.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v5[i].number << "初赛得分:" << v5[i].score << "状态: " << v5[i].sta << endl;
						}
					}
					if (b == 6) {
						cout << "第六队出场顺序编号为:" << endl;
						for (int i = 0; i < v6.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v6[i].number << "初赛得分:" << v6[i].score << "状态: " << v6[i].sta << endl;
						}
					}
					if (b == 7) {
						cout << "第七队出场顺序编号为:" << endl;
						for (int i = 0; i < v7.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v7[i].number << "初赛得分:" << v7[i].score << "状态: " << v7[i].sta << endl;
						}
					}
					if (b == 8) {
						cout << "第八队出场顺序编号为:" << endl;
						for (int i = 0; i < v8.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v8[i].number << "初赛得分:" << v8[i].score << "状态: " << v8[i].sta << endl;
						}
					}
					if (b == 9) {
						cout << "第九队出场顺序编号为:" << endl;
						for (int i = 0; i < v9.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v9[i].number << "初赛得分:" << v9[i].score << "状态: " << v9[i].sta << endl;
						}
					}
					if (b == 10) {
						cout << "第十队出场顺序编号为:" << endl;
						for (int i = 0; i < v10.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v10[i].number << "初赛得分:" << v10[i].score << "状态: " << v10[i].sta << endl;
						}
					}
					if (b == 11) {
						cout << "第十一队出场顺序编号为:" << endl;
						for (int i = 0; i < v11.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v11[i].number << "初赛得分:" << v11[i].score << "状态: " << v11[i].sta << endl;
						}
					}
					if (b == 12) {
						cout << "第十二队出场顺序编号为:" << endl;
						for (int i = 0; i < v12.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v12[i].number << "初赛得分:" << v12[i].score << "状态: " << v12[i].sta << endl;
						}
					}
					if (b == 13) {
						cout << "第十三队出场顺序编号为:" << endl;
						for (int i = 0; i < v13.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v13[i].number << "初赛得分:" << v13[i].score << "状态: " << v13[i].sta << endl;
						}
					}
					if (b == 14) {
						cout << "第十四队出场顺序编号为:" << endl;
						for (int i = 0; i < v14.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v14[i].number << "初赛得分:" << v14[i].score << "状态: " << v14[i].sta << endl;
						}
					}
					if (b == 15) {
						cout << "第十五队出场顺序编号为:" << endl;
						for (int i = 0; i < v15.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v15[i].number << "初赛得分:" << v15[i].score << "状态: " << v15[i].sta << endl;
						}
					}
					if (b == 16) {
						cout << "第十六队出场顺序编号为:" << endl;
						for (int i = 0; i < v16.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v16[i].number << "初赛得分:" << v16[i].score << "状态: " << v16[i].sta << endl;
						}
					}
					if (b == 17) {
						cout << "第十七队出场顺序编号为:" << endl;
						for (int i = 0; i < v17.size(); i++) {
							cout << "第" << i + 1 << "个进场的队伍参赛编号为:" << v17[i].number << "初赛得分:" << v17[i].score << "状态: " << v17[i].sta << endl;
						}
					}
					break;
				}
				case 2: {
					call();
					break;
				}
				case 0: {
					cout << "欢迎使用" << endl;
					f = false;
					break;
				}
				}
			}
			break;
		}
		case 6: {
			system("cls");
			menu1();
			graph g;
			initgraph(g);//初始化无向图
			Floyd(g);//计算距离
			bool f = true;
			while (f) {
				int s;
				cin >> s;
				switch (s) {
				case 1: {
					printinfo(g);
					break;
				}
				case 2: {
					shortpath(g);
					break;
				}
				case 0: {
					f = false;
					cout << "感谢使用" << endl;
					system("pause");
					system("cls");
					break;
				}
				}
			}
			break;
		}
		}
	}
	return 0;
}
  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值