数据结构课设预习-赛事管理系统
一:赛事信息管理
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;
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()
{
}