数据结构课程设计完整代码

#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <ctime>
#include <queue>
#include <iomanip>
using namespace std;

int Exisit = 0;     // DeleteProjet函数中,判断是否存在的标志
int VertexSum = -1; //节点数
int Flag = 6;       //前六个为无用信息
int Current = 480;  //当前时间,默认为8:00
const int MAXN = 10005;
const int INF = 0x3f3f3f3f;
int n = 10; //点数
int m = 15; //边数
int Star;   //起始点
int End;    //目标点

int dist[MAXN]; // dist数组中存储的即为起点到图中所有其他节点的最短路径长度
bool visited[MAXN];
int path[MAXN]; // path数组中存储的即为每个节点在最短路径上的前驱节点

struct Edge
{
    int v; // 目标节点,即下一个地点
    int w; // 权重,即路径长度
};

vector<Edge> graph[MAXN]; // 图

void dijkstra()
{
    memset(dist, INF, sizeof(dist)); //包含在库cstring中的menset函数,用于初始化
    memset(visited, false, sizeof(visited));
    memset(path, -1, sizeof(path)); //初始化path数组,记录每个节点的前驱节点,即在最短路径上该节点的前一个节点。初始值为-1,表示没有前驱节点

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    // 声明一个优先队列pq,用于存储待访问的节点。优先队列按节点到起点的距离从小到大排序,因此需要使用greater模板类来进行从大到小的排序。
    pq.push(make_pair(0, Star)); //将起点Star加入优先队列pq中,并将其到起点的距离设为0。
    dist[Star] = 0;
    while (!pq.empty())
    { //当队列不为空时进行循环,每次取出距离起点最近的节点u
        int u = pq.top().second;
        pq.pop(); //从优先队列pq中取出距离起点最近的节点u,并将其从队列中删除。

        if (visited[u])
        {
            continue;
        }
        visited[u] = true;

        for (int i = 0; i < graph[u].size(); i++) //遍历节点u的所有邻居节点v。
        {
            int v = graph[u][i].v;
            int w = graph[u][i].w; // 获取节点u到节点v的边权重w

            if (!visited[v] && dist[v] > dist[u] + w)
            { //未访问过v且从起点到v的距离大于从起点到u再到v的距离
                dist[v] = dist[u] + w;
                pq.push(make_pair(dist[v], v));
                path[v] = u;
            }
        }
    }
}
void InitializationDiagram()
{
    // graph[u].push_back({v, w});     点u 和点v的距离为w
    graph[1].push_back({2, 100});
    graph[1].push_back({4, 200});

    graph[2].push_back({1, 100});
    graph[2].push_back({3, 80});
    graph[2].push_back({4, 50});

    graph[3].push_back({2, 80});
    graph[3].push_back({5, 120});
    graph[3].push_back({6, 110});

    graph[4].push_back({1, 200});
    graph[4].push_back({2, 150});
    graph[4].push_back({5, 50});

    graph[5].push_back({3, 120});
    graph[5].push_back({4, 50});
    graph[5].push_back({8, 150});
    graph[5].push_back({9, 230});

    graph[6].push_back({3, 110});
    graph[6].push_back({7, 80});
    graph[6].push_back({8, 60});

    graph[7].push_back({6, 80});
    graph[7].push_back({10, 100});

    graph[8].push_back({5, 150});
    graph[8].push_back({6, 60});
    graph[8].push_back({9, 90});
    graph[8].push_back({10, 70});

    graph[9].push_back({5, 230});
    graph[9].push_back({8, 90});
    graph[9].push_back({10, 50});

    graph[10].push_back({7, 100});
    graph[10].push_back({8, 70});
    graph[10].push_back({9, 50});
}
void Introduce()
{
    int Place;
    cin >> Place;
    if (Place == 1)
    {
        ifstream infile("1.txt");
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
    if (Place == 2)
    {
        ifstream infile("2.txt");
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
    if (Place == 3)
    {
        ifstream infile("3.txt");
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
    if (Place == 4)
    {
        ifstream infile("4.txt");
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
    if (Place == 5)
    {
        ifstream infile("5.txt");
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
    if (Place == 6)
    {
        ifstream infile("6.txt");
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
    if (Place == 7)
    {
        ifstream infile("7.txt"); // 打开文件1.txt,读入数据
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
    if (Place == 8)
    {
        ifstream infile("8.txt"); // 打开文件1.txt,读入数据
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
    if (Place == 9)
    {
        ifstream infile("9.txt"); // 打开文件1.txt,读入数据
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
    if (Place == 10)
    {
        ifstream infile("10.txt"); // 打开文件1.txt,读入数据
        if (!infile.is_open())
        { // 判断文件是否打开成功
            cout << "文件打开失败!" << endl;
        }
        else
        {
            char ch;
            while (infile.get(ch))
            { // 循环读取文件中的每一个字符并输出
                cout << ch;
            }
            infile.close(); // 关闭文件
        }
    }
}

typedef struct
{
    string Number;      //参赛作品编号
    string Production;  //添加参赛作品名称
    string Campus;      //参赛学校
    string Category;    //参赛类别
    string StudentName; //参赛学生姓名
    string TeacherName; //指导老师姓名
    int DefenseTime;    //答辩时间
} StructTeam;
StructTeam t[400];          //结构体数组
vector<string> Team;        //储存队伍信息的容器
vector<StructTeam> AllTeam; //所有队伍的容器
vector<StructTeam> Room1;   //一到九号决赛室
vector<StructTeam> Room2;
vector<StructTeam> Room3;
vector<StructTeam> Room4;
vector<StructTeam> Room5;
vector<StructTeam> Room6;
vector<StructTeam> Room7;
vector<StructTeam> Room8;
vector<StructTeam> Room9;
typedef struct
{
    long long Number;   //参赛作品编号
    string Production;  //添加参赛作品名称
    string Campus;      //参赛学校
    string Category;    //参赛类别
    string StudentName; //参赛学生姓名
    string TeacherName; //指导老师姓名
} ElemType;
typedef struct BSTNode
{
    ElemType data;                   //每个结点的数据域包括参赛作品编号和其他数据项
    struct BSTNode *lchild, *rchild; //左右孩子指针
} BSTNode, *BSTree;

BSTree SearchBST(BSTree T, long long Number)
{
    //在根指针T所指二叉排序树中递归地查找某关键字等于Number的数据元素
    //若查找成功,则返回指向该数据元素结点的指针,否则返回空指针
    if ((!T) || Number == T->data.Number)
    {
        return T;
    } //查找结束
    else if (Number < T->data.Number)
    {
        return SearchBST(T->lchild, Number);
    } //在左子树中继续查找
    else
    {
        return SearchBST(T->rchild, Number);
    } //在右子树中继续查找
}

void InsertBST(BSTree &T, ElemType e)
{
    if (!T)
    {
        BSTNode *S = new BSTNode;     //生成新结点*S
        S->data = e;                  //新结点*S的数据域置为e
        S->lchild = S->rchild = NULL; //新结点*S作为叶子结点
        T = S;                        //把新结点*S链接到已找到的插入位置
    }
    else if (e.Number < T->data.Number)
    {
        InsertBST(T->lchild, e);
    } //将*S插入左子树
    else if (e.Number > T->data.Number)
    {
        InsertBST(T->rchild, e);
    } //将*S插入右子树
}

void CreatBST(BSTree &T)
{
    //依次读入一个关键字为Number的结点,将此结点插入二叉排序树T中
    T = NULL;     //将二叉排序树T初始化为空树
    ElemType e;   //容器中对应的信息放入树中
    int Flag = 6; //前六个为不重要信息
    while (Flag < Team.size())
    {
        InsertBST(T, e);
        //容器中对应的信息放入树中
        e.Number = stod(Team.at(Flag++));
        e.Production = Team.at(Flag++);

        e.Campus = Team.at(Flag++);

        e.Category = Team.at(Flag++);

        e.StudentName = Team.at(Flag++);

        e.TeacherName = Team.at(Flag++);
    }
    InsertBST(T, e);
}

void CreatNewTxt()
{                         //创建新的txt文件,用于参赛信息的修改和删除
    ofstream o1;          //创建文件输出流对象,用于写入文件
    o1.open("team1.txt"); //  创建一个team1.txt文件

    for (int i = 0; i < Team.size(); i++)
    {

        o1 << Team.at(i);
        if (i == Team.size() - 1)
        {
            break;
        }
        if (i % 6 == 5)
        {
            o1 << '\n'; //换行,很重要
        }
        else
        {
            o1 << "#";
        }
    }
    o1.close(); //关闭文件
}
void Remove(string &s) //去除字符串中的空格
{

    int index = 0;
    if (!s.empty())
    {
        while ((index = s.find('\t', index)) != string::npos) // 需要用'\t' ,不然无法清除
        {
            s.erase(index, 1);
        }
    }
}
int ASL(BSTree T, int depth)
{ //利用递归计算所有节点深度和

    if (T)
    {
        VertexSum++;
        return depth + ASL(T->rchild, depth + 1) + ASL(T->lchild, depth + 1);
    }
    else
        return 0;
}
void Add()
{                                 //往txt文件添加操作
    ofstream o;                   //创建文件输出流对象,用于写入文件
    o.open("team.txt", ios::app); //  ios::app  append 往后加
    o << '\n';                    //换行,很重要
    string Number;                //添加参赛队伍编号
    cout << "请输入参赛队伍编号:" << endl;
    cin >> Number;
    o << Number;

    o << "#";
    string Production; //添加参赛作品名称
    cout << "请输入参赛作品名称:" << endl;
    cin >> Production;
    o << Production;
    o << "#";

    string Campus; //添加参赛学校
    cout << "请输入参赛学校:" << endl;
    cin >> Campus;
    o << Campus;
    o << "#";

    string Category; //添加参赛类别
    cout << "请输入参赛类别:" << endl;
    cin >> Category;
    o << Category;
    o << "#";

    string StudentName; //添加参赛学生姓名
    cout << "请输入参赛学生姓名:" << endl;
    cin >> StudentName;
    o << StudentName;
    o << "#";

    string TeacherName; //添加指导老师姓名
    cout << "请输入指导老师姓名:" << endl;
    cin >> TeacherName;
    o << TeacherName;
    o.close(); //关闭文件
}

void Read()
{
    ifstream i;              //创建文件输入流对象,用于读取文件
    i.open("team.txt");      //  读取team.txt文件
    string Temp;             //按行读取后储存在Temp字符串
    while (getline(i, Temp)) //按行读取
    {
        Remove(Temp);               //按行读取,每一行都记录到Temp
        for (int j = 0; j < 6; j++) //每行六项数据
        {
            int Position = Temp.find('#');       //寻找#,记录#出现的位置
            string s = Temp.substr(0, Position); //字符串s记录所需要的数据
            Temp = Temp.substr(Position + 1);
            Team.push_back(s); //将队伍信息存入容器
        }
    }
    i.close(); //关闭文件
}
void ReadPlus()
{
    for (int i = 0; i < Team.size() / 6 - 1; i++) //队伍数量为循环条件
    {
        t[i].Number = Team.at(Flag++);
        t[i].Production = Team.at(Flag++);
        t[i].Campus = Team.at(Flag++);
        t[i].Category = Team.at(Flag++);
        t[i].StudentName = Team.at(Flag++);
        t[i].TeacherName = Team.at(Flag++);
        int DefenseTime1 = rand() % 5 + 6; //答辩时间6到10分钟
        t[i].DefenseTime = DefenseTime1;
        AllTeam.push_back(t[i]);
    }
}
void NumberFind(BSTree T)
{
    VertexSum = -1; //对节点数清零
    cout << "请输入参赛队伍的编号:" << endl;
    long long Number;
    cin >> Number;
    BSTree TempT1; //暂时创建一颗树储存找到的信息
    TempT1 = SearchBST(T, Number);
    if (TempT1)
    { //找到了
        cout << "参赛队伍编号:" << endl;
        cout << TempT1->data.Number << endl;
        cout << "参赛队伍编号:" << endl;
        cout << TempT1->data.Production << endl;
        cout << "参赛学校:" << endl;
        cout << TempT1->data.Campus << endl;
        cout << "赛事类别:" << endl;
        cout << TempT1->data.Category << endl;
        cout << "参赛者:" << endl;
        cout << TempT1->data.StudentName << endl;
        cout << "指导老师:" << endl;
        cout << TempT1->data.TeacherName << endl;
        cout << "当前二叉树的查找成功时的平均查找长度为: " << endl;
        int DepthSum = ASL(T, 0);
        double ASL2 = (double)DepthSum / VertexSum;
        cout << "ASL=所有节点深度和/节点数=" << DepthSum << "/" << VertexSum << "=" << ASL2 << endl;
    }
    else
    {
        cout << "查找错误!请检查队伍编号是否正确!" << endl;
    }
}
void CampusFind()
{
    int j = 0; //计数器
    string FindCampus;
    cout << "请输入要找寻的学校:" << endl;
    cin >> FindCampus;
    ElemType E1[999]; //包含结构体数组
    for (int i = 2; i < Team.size(); i += 6)
    {
        if (Team.at(i) == FindCampus)
        {
            //对各种信息赋值
            E1[j].Number = stod(Team.at(i - 2));
            E1[j].Production = Team.at(i - 1);
            E1[j].Campus = Team.at(i);
            E1[j].Category = Team.at(i + 1);
            E1[j].StudentName = Team.at(i + 2);
            E1[j].TeacherName = Team.at(i + 3);
            j++;
        }
    }
    //对结构体数字E1按照作品编号进行直接插入排序(升序):

    for (int i = 1; i < j; ++i)
    {
        E1[j] = E1[i];
        int k = i - 1;
        while (k >= 0 && E1[k].Number > E1[j].Number)
        {
            E1[k + 1] = E1[k];
            --k;
        }
        E1[k + 1] = E1[j];
    }
    //进行输出
    for (int i = 0; i < j; i++)
    {
        cout << "参赛队伍编号:" << endl;
        cout << E1[i].Number << endl;
        cout << "参赛作品名称:" << endl;
        cout << E1[i].Production << endl;
        cout << "参赛学校:" << endl;
        cout << E1[i].Campus << endl;
        cout << "赛事类别:" << endl;
        cout << E1[i].Category << endl;
        cout << "参赛者:" << endl;
        cout << E1[i].StudentName << endl;
        cout << "指导老师:" << endl;
        cout << E1[i].TeacherName << endl;
    }
}
void ChangeProject()
{ //更改信息的函数

    cout << "请输入要修改参赛编号:" << endl;
    long long FindNumber;
    cin >> FindNumber;
    for (int i = 6; i < Team.size(); i += 6)
    {
        if (FindNumber == stoll(Team.at(i))) //找到要修改的编号
        {
            cout << "你要修改的参赛信息为:" << endl; //输出要修改信息
            cout << "1 参赛编号:" << endl;
            cout << Team.at(i) << endl;
            cout << "2 参赛作品名称:" << endl;
            cout << Team.at(i + 1) << endl;
            cout << "3 参赛学校:" << endl;
            cout << Team.at(i + 2) << endl;
            cout << "4 赛事类别:" << endl;
            cout << Team.at(i + 3) << endl;
            cout << "5 参赛者:" << endl;
            cout << Team.at(i + 4) << endl;
            cout << "6 指导老师:" << endl;
            cout << Team.at(i + 5) << endl;
            Exisit = 1;
            cout << "你要修改哪一项:(输入要修改目标的编号1-6)" << endl;
            int Selection2;
            cin >> Selection2;
            switch (Selection2)
            {
            case 1:
            {
                cout << "请输入修改后的队伍编号:" << endl;
                string Modification;
                cin >> Modification;
                Team.at(i) = Modification;
                cout << "修改完成!" << endl;
                break;
            }
            case 2:
            {
                cout << "请输入修改后的参赛队伍名称:" << endl;
                string Modification;
                cin >> Modification;
                Team.at(i + 1) = Modification;
                cout << "修改完成!" << endl;
                break;
            }
            case 3:
            {
                cout << "请输入修改后的参赛学校:" << endl;
                string Modification;
                cin >> Modification;
                Team.at(i + 2) = Modification;
                cout << "修改完成!" << endl;
                break;
            }
            case 4:
            {
                cout << "请输入修改后的赛事类别:" << endl;
                string Modification;
                cin >> Modification;
                Team.at(i + 3) = Modification;
                cout << "修改完成!" << endl;
                break;
            }
            case 5:
            {
                cout << "请输入修改后的参赛者:" << endl;
                string Modification;
                cin >> Modification;
                Team.at(i + 4) = Modification;
                cout << "修改完成!" << endl;
                break;
            }
            case 6:
            {
                cout << "请输入修改后的指导老师:" << endl;
                string Modification;
                cin >> Modification;
                Team.at(i + 5) = Modification;
                cout << "修改完成!" << endl;
                break;
            }
            }
            cout << "修改后参赛信息为:" << endl; //输出修改后信息
            cout << "参赛编号:" << endl;
            cout << Team.at(i) << endl;
            cout << "参赛作品名称:" << endl;
            cout << Team.at(i + 1) << endl;
            cout << "参赛学校:" << endl;
            cout << Team.at(i + 2) << endl;
            cout << "赛事类别:" << endl;
            cout << Team.at(i + 3) << endl;
            cout << "参赛者:" << endl;
            cout << Team.at(i + 4) << endl;
            cout << "指导老师:" << endl;
            cout << Team.at(i + 5) << endl;
            CreatNewTxt();      //创建新的team1文件储存信息
            remove("team.txt"); // 删除原始team文件
            break;
        }
    }
    if (Exisit == 0)
    {

        cout << "输入的编号有误!" << endl;
    }
}

void DeleteProject() //删除参赛信息的项目
{

    long long DeleteNumber;
    cout << "请输入要删除的参赛项目编号:" << endl;
    cin >> DeleteNumber;
    int Size1 = Team.size();
    for (int i = 6; i < Size1; i += 6)
    {
        if (DeleteNumber == stoll(Team.at(i))) //找到要删除的编号
        {
            cout << "你要删除的参赛信息为:" << endl; //输出移除参赛编号以及后续的信息
            cout << "参赛编号:" << endl;
            cout << Team.at(i) << endl;
            Team.erase(Team.begin() + i);
            cout << "参赛作品名称:" << endl;
            cout << Team.at(i) << endl;
            Team.erase(Team.begin() + i);
            cout << "参赛学校:" << endl;
            cout << Team.at(i) << endl;
            Team.erase(Team.begin() + i);
            cout << "赛事类别:" << endl;
            cout << Team.at(i) << endl;
            Team.erase(Team.begin() + i);
            cout << "参赛者:" << endl;
            cout << Team.at(i) << endl;
            Team.erase(Team.begin() + i);
            cout << "指导老师:" << endl;
            cout << Team.at(i) << endl;
            Team.erase(Team.begin() + i);
            CreatNewTxt(); //创建新的team1文件储存信息
            Exisit = 1;
            remove("team.txt"); // 删除原始team文件
            cout << "删除成功!" << endl;
            break;
        }
    }
    if (Exisit == 0)
    {

        cout << "输入的编号有误!" << endl;
    }
}
void CallSystem(int Number, vector<StructTeam> &Room)
{ //决赛室的编号
    cout << Number << "号决赛室:";
    if (Room.empty())
    {
        if (!AllTeam.empty()) //还有需要比赛的队伍
        {
            Room.push_back(AllTeam.at(0)); //待比赛队伍放第一个放入决赛室然后出容器
            cout << "暂无队伍,下一个队伍编号:" << Room.at(0).Number << endl;
            AllTeam.erase(AllTeam.begin());
        }
        else
        {
            cout << "暂无队伍需要答辩" << endl;
        }
    }
    else //决赛室不可用
    {
        Room.at(0).DefenseTime--; //答辩时间减少
        cout << Room.at(0).Number << endl;
        if (Room.at(0).DefenseTime == 0) //答辩时间为0,即答辩完成
        {
            Room.erase(Room.begin()); //出房间
        }
    }
}
void Display()
{

    while (!AllTeam.empty() || !Room1.empty() || !Room2.empty() || !Room3.empty() || !Room4.empty() || !Room5.empty() || !Room6.empty() || !Room7.empty() || !Room8.empty() || !Room9.empty())
    { //待比赛队伍非空
        cout << "当前时间:";
        int Hour = Current / 60;
        int Minute = Current % 60;
        cout << setw(2) << setfill('0') << Hour << ":" << setw(2) << Minute << endl;
        CallSystem(1, Room1);
        CallSystem(2, Room2);
        CallSystem(3, Room3);
        CallSystem(4, Room4);
        CallSystem(5, Room5);
        CallSystem(6, Room6);
        CallSystem(7, Room7);
        CallSystem(8, Room8);
        CallSystem(9, Room9);
        Current++; //时间推进
    }
    if (AllTeam.empty())

    {
        cout << "当前时间:";
        int Hour = Current / 60;
        int Minute = Current % 60;
        cout << setw(2) << setfill('0') << Hour << ":" << setw(2) << Minute << endl;
        cout << "全部项目答辩完成" << endl;
        cout << "请重新选择功能" << endl;
    }
}
void Clear()
{
    AllTeam.clear();
    Team.clear();
    Room1.clear();
    Room2.clear();
    Room3.clear();
    Room4.clear();
    Room5.clear();
    Room6.clear();
    Room7.clear();
    Room8.clear();
    Room9.clear();
}
int main()
{
    srand((unsigned int)time(NULL));
    cout << "******************功能菜单**********************" << endl;
    cout << "************根据提示选择对应功能的序号***********" << endl;
    cout << "****************1 参赛队伍的增加****************" << endl;
    cout << "****************2 参赛队伍的删去****************" << endl;
    cout << "****************3 参赛队伍的修改****************" << endl;
    cout << "*********4 参赛队伍的查找(按参赛编号)**********" << endl;
    cout << "*********5 参赛队伍的查找(按学校名称)**********" << endl;
    cout << "********* 6 决赛叫号系统**************************" << endl;
    cout << "*************7 校园导游程序***********************" << endl;
    cout << "******************8 退出************************" << endl;
    cout << "*************************************************" << endl;
    BSTree T = NULL;
    while (1)
    {

        int Selection = 0;
        cin >> Selection;
        Clear();
        Read();
        if (Selection == 1)
        {

            Add();
            cout << "参赛队伍增加成功,并成功添加到team.txt文件中!" << endl;
            cout << "请重新选择功能!" << endl;
        }
        if (Selection == 2)
        {
            DeleteProject();
            if (Exisit == 1)
            {
                rename("team1.txt", "team.txt"); //对team1.txt文件重新命名为team.txt
                Exisit = 0;                      // Exisit重置
            }

            cout << "请重新选择功能!" << endl;
        }
        if (Selection == 3)
        {
            ChangeProject();
            if (Exisit == 1)
            {
                rename("team1.txt", "team.txt"); //对team1.txt文件重新命名为team.txt
                Exisit = 0;                      // Exisit重置
            }
            cout << "请重新选择功能!" << endl;
        }
        if (Selection == 4)
        {
            T = NULL;
            CreatBST(T); //创建二叉排序树
            NumberFind(T);
            cout << "请重新选择功能!" << endl;
        }
        if (Selection == 5)
        {
            CampusFind();
            cout << "请重新选择功能!" << endl;
        }
        if (Selection == 6)
        {
            ReadPlus();
            Display();
        }
        if (Selection == 7)
        {
            cout << "           编号表" << endl;
            cout << "1 三号组团" << endl;
            cout << "2 西苑食堂" << endl;
            cout << "3 明德园" << endl;
            cout << "4 文体中心" << endl;
            cout << "5 西操场" << endl;
            cout << "6 文理大楼" << endl;
            cout << "7 北苑" << endl;
            cout << "8 求索园" << endl;
            cout << "9 东苑食堂" << endl;
            cout << "10 图书馆" << endl;
            cout << endl;
            cout << "请继续选择功能:" << endl;
            cout << "1 地点简介" << endl;
            cout << "2 导航系统" << endl;
            cout << "3 退出" << endl;
            cout << "请输入:" << endl;
            int Selection1 = 0;
            cin >> Selection1;
            if (Selection1 == 1)
            {
                cout << "请输入地点编号,获取建筑物简介" << endl;
                Introduce();
                cout << endl;
                cout << "请重新选择功能:" << endl;
            }
            if (Selection1 == 2)
            {
                cout << "请输入起点和终点的编号:" << endl;

                cin >> Star >> End;      //起点,终点
                InitializationDiagram(); //初始化图
                dijkstra();
                vector<int> nodes;
                int node = End;
                while (node != -1)
                {
                    nodes.push_back(node);
                    node = path[node];
                }

                cout << "路径为: ";
                for (int i = nodes.size() - 1; i >= 0; i--)
                {
                    if (i == 0)
                    {
                        cout << nodes[i];
                    }
                    else
                    {
                        cout << nodes[i] << "——>";
                    }
                }
                cout << endl;
                cout << "最短路径长度为: " << dist[End] << endl;
                cout << "请继续选择功能:" << endl;
            }
        }
        if (Selection == 8)
        {
            break;
        }
    }
    system("pause");
    return 0;
}
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值