【无标题】

本文介绍了在数据结构课程中,关于一个赛事管理系统的预习内容,包括队伍信息的存储与操作(如数据储存、文件读写、随机成绩设置和增删改查),决赛现场模拟(分组和模拟)以及地图导航(构建邻接矩阵和求最短路径)的相关实现方法。
摘要由CSDN通过智能技术生成

数据结构课设预习-赛事管理系统

一:赛事信息管理

1.数据储存

vector<team> allteam;//存储所有参赛队伍
class team
{
public:
	team() {};
	team(string id, string workname, string schname, string compname, string stuname, string teaname)
	{
		this->id = id; 
		this->workname = workname;
		this->schname = schname;
		this->compname = compname;
		this->stuname = stuname;
		this->teaname = teaname;
	}
private:
	string id;
	string workname;
	string schname;
	string compname;
	string stuname;
	string teaname;
	int score;
};

2.文件获取写入数据

void team::readfile()
{
	allteam.clear();
	ifstream ifs;
	ifs.open("team.txt", ios::in);
	string str;
	team t;
	if (!ifs.is_open())
	{
		cout << "文件打开失败";
		return;
	}
	while (getline(ifs, str))
	{
		string::iterator st = str.begin();
		for (; st != str.end(); st++)
		{
			if (*st == ' ')
			{
				str.erase(st);//去除空格
			}
		}
		vector<string>str1;
		string s;
		stringstream ss(s);
		while (getline(ss, s, '#'))//字符流分割依次输入
		{
			str1.push_back(s);
		}
			team t(str1[0], str1[1], str1[2], str1[3], str1[4], str1[5]);
	allteam.push_back(t);
}
ifs.close();

3.随机成绩

void team::scored()
{
	int i = 0;
	while (i < allteam.size())
	{
		allteam[i].score = rand() % 100 + 1;//1到100
		i++;
	}
}

4.增加、删除、修改队伍信息

void team::addteam(string id, string workname, string schname, string compname, string stuname, string teaname)
{
	ofstream ofs;
	ofs.open("team.txt", ios::app);//添加打开
	ofs << id << "      #" << workname << "      #" << schname << "      #" << compname << "      #" << stuname << "      #" << teaname << endl;
	ofs.close();
	cout << "添加成功";
	system("pause");
	system("cls");//清屏
}
void team::deleteteam(string id)
{
	for (int i = 0; i < allteam.size(); i++)
	{
		if (allteam[i].getid() == id)
		{
			allteam.erase(allteam.begin() + i);
			cout << "删除成功";
			break;
		}
	}
	ofstream ofs;
	ofs.open("team.txt", ios::ate);
	for (int i = 0; i < allteam.size(); i++)
	{
		ofs << id << "      #" << workname << "      #" << schname << "      #" << compname << "      #" << stuname << "      #" << teaname << endl;
	}
	ofs.close();
	system("pause");
	system("cls");
}
void team::reviseteam(string id, string workname, string schname, string compname, string stuname, string teaname)
{
	
	for (int i = 0; i < allteam.size(); i++)
	{
		if (allteam[i].getid() == id)
		{
			cout << "请输入参赛作品名称:" << endl;
			cin >> workname;
			cout << "请输入参赛参赛学校:" << endl;
			cin >> schname;
			cout << "请输入参赛的赛事类别:" << endl;
			cin >> compname;
			cout << "请输入参赛者:" << endl;
			cin >> stuname;
			cout << "请输入参赛的指导老师:" << endl;
			cin >> teaname;
			allteam[i] = { id, workname, schname, compname, stuname, teaname };
			cout << "修改成功" << endl;
		}
	}
	system("pause");
	system("cls");
}

二:决赛现场模拟

1.决赛分组生成秩序册

void team::teamd()//分组
{

}

2.决赛模拟

void team::simulate()//模拟
{

}

三:地图导航

1.构建带权邻接矩阵

struct tu//结点
{
	int ver;
	string name;
	string show;
};
void team::graph()//无向图
{
	
}

2.求出与目的地的最短路径

void team::nevi()//导航
{

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值