校园导游系统(课程设计)

这个是本人的课程设计的代码,论文已上传资源。
代码:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define MVNum 100
#define MaxInt 32767                                  /*最大值*/
using namespace std;
void gotoxy(int y, int x);
struct AMGraphd
{
    string vexs[MVNum];                               /*顶点表*/
    int arcs[MVNum][MVNum];                           /*邻接矩阵*/
    int vexnum;                                       /*图的当前点数*/
    int arcnum;                                       /*边数*/
    string info[MVNum];                               /*景点介绍*/
}G;
int S[11100], D[11100], Path[11100], minn, ts = 5;
char stra[][3] = {"欢", "迎", "进", "入", "郑", "州", "升", "达", "经", "贸", "管", "理", "学", "院", "校", "园", "导", "游", "系", "统"};
char strb[][3] = {"请", "按", "回", "车", "进", "入"};
//-------------------------------------------
void log()                                     /*打印欢迎界面*/
{
    char c;
    int m = 25, n = 10;
    bool t = true, temp = true, flag = false;
    while (true)                               /*循环边框*/
    {
        for (int i = 6; i <= 80; i += 2)       /*打印第一行边框*/
        {
            gotoxy(n, i + m);                  /*光标跳到第n行i+m列处,向右打印*/
            if (t)                             /*空心和实心相互打印*/
                cout << "☆";
            else cout << "★";
            if (temp && i >= 22 && i <= 60)    /*向右打印文字*/
            {
                gotoxy(n + 10, i + m + 3);     /*光标跳到中间,打印中间文字*/
                cout << stra[(i - 22) / 2];    /*打印第一行中间文字*/
            }
            if (kbhit())                       /*判断是否有按键的操作*/
            {
                c = getch();
                if (c == '\r')                 /*回车键退出循环,进入主菜单*/
                {
                    flag = true;
                    break;
                }
            }
            t = !t;
            Sleep(ts);                         /*控制边框打印的速度*/
        }
        if (flag) break;                       /*进入主菜单*/
        for (int i = 0; i <= 25; i++)          /*打印第二列边框*/
        {
            gotoxy(i + n, m + 82);             /*向下打印*/
            if (t)
                cout << "☆";                  /*同上*/
            else cout << "★";
            if (kbhit())
            {
                c = getch();
                if (c == '\r')
                {
                    flag = true;
                    break;
                }
            }
            t = !t;
            Sleep(ts);
        }
        if (flag) break;
        for (int i = 82; i >= 6; i -= 2)       /*打印第二行边框*/
        {
            gotoxy(n + 25, i + m);             /*向左打印*/
            if (t)
                cout << "★";
            else cout << "☆";
            if (temp && i >= 44 && i <= 54)    /*向左打印文字*/
            {
                gotoxy(n + 15, i + m - 5);     /*光标跳到中间,打印中间文字*/
                cout << strb[(i - 44) / 2];    /*打印第二行中间文字*/
            }
            if (kbhit())                       /*同上*/
            {
                c = getch();
                if (c == '\r')
                {
                    flag = true;
                    break;
                }
            }
            t = !t;
            Sleep(ts);
        }
        if (flag) break;
        for (int i = 25; i >= 1; i--)
        {
            gotoxy(i + n, m + 6);            /*向上打印*/
            if (t)
                cout << "☆";                /*同上*/
            else cout << "★";
            if (kbhit())
            {
                c = getch();
                if (c == '\r')
                {
                    flag = true;
                    break;
                }
            }
            t = !t;
            Sleep(ts);
        }
        t = !t;
        temp = false;
        if (flag) break;
    }
    gotoxy(35, 0);
}
//-------------------------------------------
char menu()                                             /*打印主菜单界面*/
{
    char c;
    system("CLS");                                      /*清屏*/
    int m = 25, n = 5;
    bool t = true, temp = true, flag = false;
    cout << "\n\n\n\n\n\n\n\n\n\n";
    cout << "\t\t\t\t\t * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *\n";
    cout << "\t\t\t\t\t * *                     *校园导航*                     * *\n";
    cout << "\t\t\t\t\t * ****************************************************** *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *                   1.*显示地图*.1                   * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *                     2.*导航*.2                     * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *                   3.*景点遍历*.3                   * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *                   4.*景点查询*.4                   * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *                   0.*退出系统*.0                   * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * ****************************************************** *\n";
    cout << "\t\t\t\t\t * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *\n";
    while (true)                        /*用循环来控制系统一直工作*/ 
    {
        for (int i = 6; i <= 80; i += 2)/*同上,打印边框 */
        {
            gotoxy(n, i + m);
            if (t)
                cout << "☆";
            else cout << "★";
            if (kbhit())
            {
                c = getch();
                if (c >= '0' && c <= '4')/*判断是否为有效数字*/
                {
                    flag = true;
                    break;
                }
            }
            t = !t;
            Sleep(ts);
        }
        if (flag) break;
        for (int i = 0; i <= 25; i++)
        {
            gotoxy(i + n, m + 82);
            if (t)
                cout << "☆";
            else cout << "★";
            if (kbhit())
            {
                c = getch();
                if (c >= '0' && c <= '4')/*判断是否为有效数字*/
                {
                    flag = true;
                    break;
                }
            }
            t = !t;
            Sleep(ts);
        }
        if (flag) break;
        for (int i = 82; i >= 6; i -= 2)
        {
            gotoxy(n + 25, i + m);
            if (t)
                cout << "★";
            else cout << "☆";
            if (kbhit())
            {
                c = getch();
                if (c >= '0' && c <= '4')/*判断是否为有效数字*/
                {
                    flag = true;
                    break;
                }
            }
            t = !t;
            Sleep(ts);
        }
        if (flag) break;
        for (int i = 25; i >= 1; i--)
        {
            gotoxy(i + n, m + 6);
            if (t)
                cout << "☆";
            else cout << "★";
            if (kbhit())
            {
                c = getch();
                if (c >= '0' && c <= '4')/*判断是否为有效数字*/
                {
                    flag = true;
                    break;
                }
            }
            t = !t;
            Sleep(ts);
        }
        t = !t;
        temp = false;
        if (flag) break;
    }
    gotoxy(35, 0);//使光标跳回到原处 
    return c;
}
//-------------------------------------------
void view_map()                        /*查看地图*/
{
    char c;
    FILE *fp;                        /*定义文件指针*/
    system("CLS");                    /*清屏*/
    fp = fopen("map.txt", "r");        /*打开文件*/
    while (~fscanf(fp, "%c", &c))    /*从文件读入地图*/
        cout << c;
    fclose(fp);                        /*关闭文件*/
    while (c = getch(), c != '\r');    /*回车返回菜单*/
}
//-------------------------------------------
int LocateVex(AMGraphd G, string u)    /*查找景点的下标*/
{
    int i = 1;
    G.vexs[G.vexnum + 1] = u;        /*带有哨兵的查找*/
    while (G.vexs[i] != u) i++;        /*不符合,查找下一个*/
    return i;
}
//-------------------------------------------
int CreateUD(AMGraphd  &G)            /*初始化数据*/
{
    FILE *fp;                        /*定义文件指针*/
    system("CLS");                    /*清屏*/
    //-------------------------------------------//初始化每个景点的编号和简介 
    G.vexs[1] = "正大门"; G.info[1] = "学校正门";
    G.vexs[2] = "北生活馆"; G.info[2] = "生活馆,一楼是一些商店";
    G.vexs[3] = "体育场"; G.info[3] = "学校操场,经常有学生去锻炼身体";
    G.vexs[4] = "体育馆"; G.info[4] = "室内运动场所";
    G.vexs[5] = "艺术楼"; G.info[5] = "内设音乐厅、专业舞蹈排练厅、琴房、专业录音棚、音乐教室、数码钢琴教室、电脑音乐(MIDI)制作教室、阶梯素质教室、器乐排练教室、专业合唱排练教室等,是艺术专业师生理想的求知殿堂";
    G.vexs[6] = "27/15/17宿舍楼"; G.info[6] = "27、15、17号宿舍楼";
    G.vexs[7] = "升达餐厅"; G.info[7] = "学校餐厅,是学校装修靠前的餐厅";
    G.vexs[8] = "16/18宿舍楼"; G.info[8] = "16、18号宿舍楼";
    G.vexs[9] = "外语楼"; G.info[9] = "外语一号楼,主要供外语系师生在此办公、学习,外语二号楼,主要供公共外语部在此办公";
    G.vexs[10] = "教学楼1/2"; G.info[10] = "教学1-4号馆是学院一期工程建设的教学楼,楼内设有主教室、办公室、教师休息室、会议室等,全部仿照中国传统建筑四合院的形式建造,每两楼一体";
    G.vexs[11] = "龙湖食府"; G.info[11] = "一楼是餐厅,二楼为龙湖报告厅,是一些小型会议的举办场所";
    G.vexs[12] = "思源会馆"; G.info[12] = "正门是创办人纪念馆,后面配置有各种现代化会议所需电子设备,是接待中型高端会议、报告会及其它会议的一个重要场所";
    G.vexs[13] = "行政楼"; G.info[13] = "行政大楼位于学院中轴线,具有完整的区域功能,是集办公、会议、接待为一体的场所。";
    G.vexs[14] = "艺文广场"; G.info[14] = "学校图书馆,有五层书库,自习室,电子阅览室等";
    G.vexs[15] = "博新楼"; G.info[15] = "一二楼设有食堂和一些生活必需品的店,三楼是一些社团活动室";
    G.vexs[16] = "13宿舍楼"; G.info[16] = "13号宿舍楼";
    G.vexs[17] = "7~12宿舍楼"; G.info[17] = "7到12号学生宿舍";
    G.vexs[18] = "无名湖"; G.info[18] = "学校一景,有个凉亭";
    G.vexs[19] = "后山篮球场"; G.info[19] = "篮球场,篮球爱好者常去的地方";
    G.vexs[20] = "30/32宿舍楼"; G.info[20] = "30、32号宿舍楼";
    G.vexs[21] = "时金/道镕楼"; G.info[21] = "分别为了感谢和纪念林时金先生和范道镕先生对升达建设和发展作出的重要贡献而命名的大楼";
    G.vexs[22] = "资讯/商管楼"; G.info[22] = "第一、第二实验大楼,是学院开展实践教学的重要场所,能较好的满足学院各专业的教学需求";
    G.vexs[23] = "教学楼4/3"; G.info[23] = "教学1-4号馆是学院一期工程建设的教学楼,楼内设有主教室、办公室、教师休息室、会议室等,全部仿照中国传统建筑四合院的形式建造,每两楼一体";
    G.vexs[24] = "综合楼"; G.info[24] = "综合大楼由综合楼和自勉堂对接,形成“口”字形,是我院建设较早的集教学、实习于一体的综合性大楼。";
    G.vexs[25] = "图书馆"; G.info[25] = "学校图书馆,有三层书库,自习室,电子阅览室等";
    G.vexs[26] = "新建图书馆"; G.info[26] = "正在建设的图书馆";
    G.vexs[27] = "邂逅时光"; G.info[27] = "学生娱乐消费的高档地方";
    G.vexs[28] = "后山1"; G.info[28] = "学校的树林区,也有不错的风景";
    G.vexs[29] = "后山2"; G.info[29] = "学校的树林区,也有不错的风景";
    G.vexs[30] = "后山3"; G.info[30] = "学校的树林区,也有不错的风景";
    G.vexs[31] = "后山4"; G.info[31] = "学校的树林区,也有不错的风景";
    G.vexs[32] = "31宿舍楼"; G.info[32] = "学生31号宿舍楼";
    G.vexs[33] = "建工大楼"; G.info[33] = "建工大楼是集教学、实验、成果展示、资料阅览等多功能的教学科研大楼,是学院的地标性建筑";
    G.vexs[34] = "南食堂"; G.info[34] = "餐厅,饭挺不错的";
    //-------------------------------------------//
    G.vexnum = 34;                        /*顶点数*/
    G.arcnum = 51;                        /*边数*/
    fp = fopen("Weight.txt", "r");        /*打开权值文件*/
    int ans = 0, ans1 = 0;
    for (int i = 1; i <= G.vexnum; i++)
        for (int j = 1; j <= G.vexnum; j++)
        {
            fscanf(fp, "%d", &G.arcs[i][j]);        /*从文件读入权值*/
            if (!G.arcs[i][j])
                G.arcs[i][j] = MaxInt;    /*没边的设置为最大值*/
        }
    fclose(fp);                            /*关闭文件*/
    return 0;
}
//-------------------------------------------
void List()                        /*打印景点列表*/
{
    char c;
    system("CLS");                /*清屏*/
    cout << "\n\n\n\n";
    cout << "\t\t\t\t\t * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *\n";
    cout << "\t\t\t\t\t * *                     *景点列表*                     * *\n";
    cout << "\t\t\t\t\t * ****************************************************** *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *  <1> 正大门  <2> 北生活馆  <3> 体育场  <4> 体育馆  * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *    <5> 艺术楼  <6> 27/15/17宿舍楼  <7> 升达餐厅    * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *    <8> 16/18宿舍楼  <9> 外语楼  <10> 教学楼1/2     * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *     <11> 龙湖食府  <12> 思源会馆  <13> 行政楼      * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *     <14> 艺文广场  <15> 博新楼  <16> 13宿舍楼      * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *   <17> 7~12宿舍楼  <18> 无名湖 <19> 后山篮球场     * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *<20> 30/32宿舍楼  <21> 时金/道镕楼  <22> 资讯/商管楼* *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *      <23> 教学楼4/3  <24> 综合楼  <25> 图书馆      * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *     <26> 新建图书馆  <27> 邂逅时光  <28> 后山1     * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *         <29> 后山2  <30> 后山3  <31> 后山4         * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * *      <32> 31宿舍楼  <33> 建工大楼  <34> 南食堂     * *\n";
    cout << "\t\t\t\t\t * *                                                    * *\n";
    cout << "\t\t\t\t\t * ****************************************************** *\n";
    cout << "\t\t\t\t\t * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *\n";
    cout << "\t\t\t\t\t                        按\"*\"键返回                      \n";
}
//-------------------------------------------
char mode()                        /*判断是编号查询还是名称查询*/
{
    int c; 
    cout << "\t\t\t\t\t                       请输入查询方式                      \n";
    cout << "\t\t\t\t\t                        1.编号查询.1                       \n";
    cout << "\t\t\t\t\t                        2.名称查询.1                       \n";
    cout << "\t\t\t\t\t                        *.返回菜单.*                       \n";
    while (c = getch(), (c < '1' || c > '2') && c != '*');
    return c;
}
//-------------------------------------------
void Dijkstra(int v0, int z)    /*迪杰斯特拉求最短路*/
{
    int i, n, v, w;
    n = G.vexnum;
    for (v = 1; v <= n; v++)    /*变量初始化*/
    {
        S[v] = false;
        D[v] = G.arcs[v0][v];
        if (D[v] < MaxInt)        /*判断能否到达v*/
            Path[v] = v0;        /*能到达,则他的上一站就为v0*/
        else Path[v] = -1;        /*不能到达,初始化-1*/
    }
    D[v0] = 0;                    /*v0到v0的距离为0*/
    S[v0] = true;                /*标记访问过的顶点*/
    for (i = 1; i < n; i++)
    {
        minn = MaxInt;
        for (w = 1; w <= n; w++)
        {
            if (!S[w] && D[w] < minn)    /*找到v0能到达的最短的边*/
            {
                v = w;
                minn = D[w];
            }
        }
        S[v] = true;                    /*标记*/
        for (w = 1; w <= n; w++)
        {
            if (!S[w] && D[v] + G.arcs[v][w] < D[w])/*判断一下用该边能否松弛其它的边*/
            {
                Path[w] = v;                        /*记录路线*/
                D[w] = D[v] + G.arcs[v][w];            /*用这个边来松弛其它的边*/
            }
        }
    }
    int s = z;
    stack  S;            /*定义一个栈*/
    while (Path[s] != v0)
    {
        S.push(Path[s]);    /*进栈,先把路线存到栈里面,方便正序打印*/
        s = Path[s];
    }
    cout << endl << "路线为:" << endl;            /*打印路线*/
    cout << G.vexs[v0] << " --> ";                /*打印起点*/
    while (!S.empty())
    {
        cout << G.vexs[S.top()] << " --> ";        /*打印中间点*/
        S.pop();                                /*出栈*/
    }
    cout << G.vexs[z] << endl;                    /*打印终点*/
    cout <<"最短距离为:" << D[z] << "m" << endl;/*输出最短距离*/
}
//-------------------------------------------
void navigation()                                /*查询任意两点的最短路*/
{
    char ch;
    string a, b;
    int i, n, v0, w, z;
    while (true)
    {
        system("CLS"); 
        ch = mode();                            /*判断查询方式*/
        if (ch == '*')                            /*"*"号返回菜单*/
            return ;
        List();                                    /*输出景点列表*/
        cout << "请输入当前位置:";
            cin >> a;                            /*输入起点*/
        if (a[0] == '*')                        /*"*"号返回菜单*/
            return ;
        if (ch == '1')                            /*编号查询*/
            for (v0 = 0, i = 0; a[i]; i++)
                v0 = v0 * 10 + a[i] - '0';        /*计算编号*/
        else v0 = LocateVex(G, a);                /*名称查询,查找编号*/
        while (v0 > G.vexnum || v0 <= 0)        /*非法输入,重新输入*/
        {
            cout << "查询不到该位置,请重新输入!\n";
            cout << "请输入当前位置:";
            cin >> a;
            if (a[0] == '*')
                return ;
            if (ch == '2')
                v0 = LocateVex(G, a);
            else for (v0 = 0, i = 0; a[i]; i++)    /*同上*/
                v0 = v0 * 10 + a[i] - '0';
        }
        cout << "请输入终点位置:";
        cin >> b;                            /*输入终点*/
        if (b[0] == '*')
            return ;
        if (ch == '1')
            for (z = 0, i = 0; b[i]; i++)
                z = z * 10 + b[i] - '0';
        else z = LocateVex(G, b);
        while (z > G.vexnum || z <= 0 || v0 == z)
        {
            if (v0 == z)
                cout << "终点和起点相同,请重新输入!\n";
            else cout << "查询不到该位置,请重新输入!\n";
            cout << "请输入终点位置:";
            cin >> b;                            /*输入终点*/
            if (b[0] == '*')
                return ;
            if (ch == '1')
            for (z = 0, i = 0; b[i]; i++)
                z = z * 10 + b[i] - '0';
            else z = LocateVex(G, b);            /*同上*/
        }
        Dijkstra(v0, z);                        /*求单源最短路*/
        printf("\n请按回车键继续!\n");
        while (ch = getch(), ch != '\r' && ch != '*');/*暂停一下,查看结果,回车继续导航,"*"返回菜单*/
        if (ch == '*')
            return ;
    }
}
//-------------------------------------------
void Traversing()                                /*查询某顶点到所有顶点的最短路线*/
{
    char ch;
    string a;
    int i, n, v0, w;
    while (true)
    {
        system("CLS");
        ch = mode();                            /*判断查询方式*/
        if (ch == '*')                            /*"*"号返回菜单*/
            return ;
        List();                                    /*输出景点列表*/
        cout << "请输入当前位置:";
            cin >> a;                            /*输入起点*/
        if (a[0] == '*')                        /*"*"号返回菜单*/
            return ;
        if (ch == '1')                            /*编号查询*/
            for (v0 = 0, i = 0; a[i]; i++)
                v0 = v0 * 10 + a[i] - '0';        /*计算编号*/
        else v0 = LocateVex(G, a);                /*名称查询*/
        while (v0 > G.vexnum || v0 <= 0)        /*非法输入,重新输入*/
        {
            cout << "查询不到该位置,请重新输入!\n";
            cout << "请输入当前位置:";
            cin >> a;                            /*同上*/
            if (a[0] == '*')
                return ;
            if (ch == '2')
                v0 = LocateVex(G, a);
            else for (v0 = 0, i = 0; a[i]; i++)
                v0 = v0 * 10 + a[i] - '0';
        }
        for (i = 1; i <= G.vexnum; i++)
        {
            if (i != v0)
                Dijkstra(v0, i);                /*除去起点,打印所有最短距离*/
        }
        printf("\n请按回车键继续!\n");
        while (ch = getch(), ch != '\r' && ch != '*');/*暂停一下,查看结果,回车继续,"*"返回菜单*/
        if (ch == '*')
            return ;
    }
}
//-------------------------------------------
void Introduction()                                /*查询景点简介*/
{
    int f, i;
    char ch;
    string s;
    while (true)
    {
        system("CLS");
        ch = mode();
        if (ch == '*')
            return ;
        List();
        cout << "请输入景点:";
        cin >> s;                                /*输入起点*/
        if (s[0] == '*')
            return ;
        if (ch == '1')
            for (f = 0, i = 0; s[i]; i++)
                f = f * 10 + s[i] - '0';
        else f = LocateVex(G, s);
        while (f > G.vexnum || f <= 0)            /*非法输入*/
        {
            cout << "查询不到该位置,请重新输入!\n";
            cout << "请输入景点:";
            cin >> s;                            /*输入起点*/
            if (s[0] == '*')
                return ;
            if (ch == '1')
                for (f = 0, i = 0; s[i]; i++)
                    f = f * 10 + s[i] - '0';    /*同上*/
            else f = LocateVex(G, s);
        }
        if (ch == '1')
            s = G.vexs[f];
        cout << s << "的简介为:" << endl;
        cout << G.info[f] << endl;                /*打印简介*/
        printf("\n请按回车键继续!\n");
        while (ch = getch(), ch != '\r' && ch != '*');/*暂停一下,查看结果,回车继续,"*"返回菜单*/
        if (ch == '*')
            return ;
    }
}
//-------------------------------------------
int main()
{
    system("title 校园导游程序设计");    /*设置标题*/
    system("mode con cols=140 lines=245");                /*设置窗口大小*/
    log();                                                /*进入欢迎界面*/
    CreateUD(G);                                        /*数据初始化*/
    while (true)
    {
        char n;
        n = menu();                                        /*进入主菜单界面*/
        switch(n)
        {
            case '0': exit(0);                                     /*输入为零,退出系统*/
            case '1': view_map(); break;                          /*查看地图*/
            case '2': navigation(); break;                        /*导航*/
            case '3': Traversing(); break;                        /*查询某一顶点到其它顶点的最短距离*/
            case '4': Introduction(); break;                    /*查询景点简介*/
        }
    }
    return 0;
}
//-------------------------------------------
void gotoxy(int y, int x)                                        /*将光标移动到坐标为(x,y)的地方*/
{
    CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
    HANDLE hConsoleOut;
    hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hConsoleOut, &csbiInfo);
    csbiInfo.dwCursorPosition.X = x;
    csbiInfo.dwCursorPosition.Y = y;
    SetConsoleCursorPosition(hConsoleOut, csbiInfo.dwCursorPosition);
}

注意下面的文件要和代码放在一个目录下,格式有可能不对,不过放到文本中改成宋体就行了。
List.txt:


                                         * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *
                                         * *                     *景点列表*                     * *
                                         * ****************************************************** *
                                         * *                                                    * *
                                         * *  <1> 正大门  <2> 北生活馆  <3> 体育场  <4> 体育馆  * *
                                         * *                                                    * *
                                         * *    <5> 艺术楼  <6> 27/15/17宿舍楼  <7> 升达餐厅    * *
                                         * *                                                    * *
                                         * *    <8> 16/18宿舍楼  <9> 外语楼  <10> 教学楼1/2     * *
                                         * *                                                    * *
                                         * *     <11> 龙湖食府  <12> 思源会馆  <13> 行政楼      * *
                                         * *                                                    * *
                                         * *     <14> 艺文广场  <15> 博新楼  <16> 13宿舍楼      * *
                                         * *                                                    * *
                                         * *   <17> 7~12宿舍楼  <18> 无名湖 <19> 后山篮球场     * *
                                         * *                                                    * *
                                         * *<20> 30/32宿舍楼  <21> 时金/道镕楼  <22> 资讯/商管楼* *
                                         * *                                                    * *
                                         * *      <23> 教学楼4/3  <24> 综合楼  <25> 图书馆      * *
                                         * *                                                    * *
                                         * *      <26> 新建图书馆  <27> 邂逅时光  <28> 后山     * *
                                         * *                                                    * *
                                         * *      <29> 31宿舍楼  <30> 建工大楼  <31> 南食堂     * *
                                         * *                                                    * *
                                         * ****************************************************** *
                                         * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *

map.txt:


                                                                                                            ╔═══════╗
                                                                                                            ║              ║
                                                  请按回车键返回主菜单                                      ║   33宿舍楼   ║
                                                                                                            ║     *33      ║
                                                                                                            ║   建工大楼   ║
                                                                                                            ╚═══════╝
  ╔══════╗  ╔═══╗╔═══╗╔═══╗╔═════╗╔══════╗╔═══╗╔═══════╗╔═══════╗
  ║            ║  ║      ║║      ║║      ║║          ║║            / /        \ \              ║║              ║
  ║    *21     ║  ║ *22  ║║ *23  ║║ *24  ║║   *25    ║║ 新图书馆  / /          \ \             ║║              ║
  ║   时  道   ║  ║资  商║║教  教║║自勉堂║║          ║║          / /  ╔══╗  \ \    后山1   ║║     后山2    ║
  ║            ║  ║      ║║学  学║║      ║║  图书馆  ║║ 建设中  / /   /      \   \ \           ║║              ║╔══╗
  ║   金  镕   ║  ║讯  管║║楼  楼║║      ║║          ║║        / /   /  1到6  \   \ \          ║║              ║║ 31 ║
  ║            ║  ║      ║║4   3 ║║综合楼║║          ║║ *26   / /   /  宿舍楼  \   \ \         ║║              ║║ 宿 ║
  ║   楼  楼   ║  ║楼  楼║║      ║║      ║║          ║║      / /   /    *27     \   \ \   *28  ║║     *29      ║║ 舍 ║
  ║            ║  ║      ║║      ║║      ║║          ║║     / /   /   邂逅时光   \   \ \       ║║              ║║*32 ║
  ╚══════╝  ╚═══╝╚═══╝╚═══╝╚═════╝╚══╝╚═╩═══════╩═╝╚═══╝╚═══════╝╚══╝
  ╔══════╗  ╔═══╗╔═══╗╔═══╗╔═════╗╔═══╗╔══╗╔═══╗╔══╗╔══╗╔═══════╗╔══╗
  ║            ║  ║      ║║      ║║ 龙湖 ║║          ║║      ║║ 南 ║║ *17  ║║    ║║    ║║              ║║    ║
  ║ 29    北   ║  ║  外  ║║教  教║║ 食府 ║║   明德   ║║      ║║ 食 ║║ 7 10 ║║    ║║    ║║              ║║ 30 ║
  ║       生   ║  ║      ║║学  学║║      ║║          ║║  高  ║║ 堂 ║║ 8 11 ║║    ║║    ║║              ║║    ║
  ║ 28    活   ║  ║  语  ║║楼  楼║║ 品途 ║║   讲坛   ║║  尔  ║║*34 ║║ 9 12 ║║    ║║    ║║    *后 山4   ║║ 32 ║
  ║       馆   ║  ║      ║║2   1 ║║ 餐厅 ║║          ║║  夫  ║║    ║║ 宿舍 ║║ 无 ║║ 后 ║║              ║║    ║
  ║ 宿    篮   ║  ║  楼  ║║      ║║  *11 ║║          ║║  学  ║╚══╝║  楼  ║║    ║║ 山 ║║     *31      ║║ 宿 ║
  ║ 舍    球   ║  ║      ║║      ║╚═══╝║          ║║  院  ║╔══╗╚═══╝║ 名 ║║ 3  ║║              ║║    ║
  ║ 楼    场   ║  ║  *9  ║║ *10  ║╔═══╗║  行政楼  ║║      ║║ 博 ║╔═══╗║    ║║    ║╚═══════╝║ 舍 ║
  ║            ║  ╚═══╝╚═══╝║ 思源 ║║          ║║ 艺文 ║║    ║║ *16  ║║ 湖 ║║    ╚═╗╔═════╗║    ║
  ║  北生活馆  ║  ╔════════╗║ 会馆 ║║          ║║ 广场 ║║ 新 ║║13宿舍║║    ║║ *30    ║║          ║║ 楼 ║
  ║            ║  ║                ║║ *12  ║║   *13    ║║ *14  ║║*15 ║║  楼  ║║*18 ║║        ║║后山篮球场║║    ║
  ║ 26 25 24 23║  ║     网排篮     ║╚═══╝╚═════╝╚═══╝╚══╝╚═══╝╚══╝╚════╝║          ║║*20 ║
  ║ 19 20 21 22║  ║      球场      ║╔══════╗  ╔══════════╗╔══╗ ╔════════╗ ║   *19    ║║    ║
  ║   宿舍楼   ║  ║                ║║            ║  ║ 艺 术 楼  信阳餐厅 ║║ 升达 \ \      ╔════╝ ╚═════╝╚══╝
  ║            ║  ║                ║║            ║  ║                    ║║ 餐厅  \ \    /         ╔═══════╗
  ║  北区澡堂  ║  ║                ║║            ║*1║           教工宿舍 ║║  *7    \╚═╝ ╔═══╝16/18宿舍楼 *8║
  ║            ║小║     体育场     ║║   体育馆   ║正║    *5              ║╚════╝      ╚═══════════╝
  ║     *2     ║北║       *3       ║║     *4     ║大║            14号楼  ║╔════════════════════╗
  ║            ║门║                ║║            ║门║                    ║║                   *6   27/15/17 宿舍楼 ║
  ╚══════╝  ╚════════╩╩══════╝  ╚══════════╝╚════════════════════╝

Weight.txt:

  0   0   0  50 200   0   0   0   0   0   0   0 200   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
  0   0 120   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 210   0   0   0   0   0   0   0   0   0   0   0   0   0
  0 120   0   0   0   0   0   0 110   0   0 150   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
 50   0   0   0   0   0   0   0   0   0   0 160   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
200   0   0   0   0   0 140   0   0   0   0   0   0  14   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
  0   0   0   0   0   0 190 100   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
  0   0   0   0 140 190   0   0   0   0   0   0   0   0   0 100   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
  0   0   0   0   0 100   0   0   0   0   0   0   0   0   0   0   0   0 200   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
  0   0 110   0   0   0   0   0   0 290   0   0   0   0   0   0   0   0   0   0   0 100   0   0   0   0   0   0   0   0   0   0   0   0
  0   0   0   0   0   0   0   0 290   0 220   0   0   0   0   0   0   0   0   0   0   0  90   0   0   0   0   0   0   0   0   0   0   0
  0   0   0   0   0   0   0   0   0 220   0 220   0   0   0   0   0   0   0   0   0   0   0  20   0   0   0   0   0   0   0   0   0   0
  0   0 150 160   0   0   0   0   0   0 220   0  70   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
200   0   0   0   0   0   0   0   0   0   0  70   0 140   0   0   0   0   0   0   0   0   0   0 140   0   0   0   0   0   0   0   0   0
  0   0   0   0  14   0   0   0   0   0   0   0 140   0  70   0   0   0   0   0   0   0   0   0   0 140   0   0   0   0   0   0   0 150
  0   0   0   0   0   0   0   0   0   0   0   0   0  70   0  70   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 200
  0   0   0   0   0   0 100   0   0   0   0   0   0   0  70   0 150 200   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 150   0   0   0   0   0   0   0   0   0   0  60   0   0   0   0   0   0  50
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 200   0   0 200   0   0   0   0   0   0   0   0   0   0 150   0   0   0   0
  0   0   0   0   0   0   0 200   0   0   0   0   0   0   0   0   0 200   0 100   0   0   0   0   0   0   0   0   0 100 100   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 100   0   0   0   0   0   0   0   0   0   0   0 100 100   0   0
  0 210   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 120   0   0   0   0   0   0   0   0   0   0   0   0
  0   0   0   0   0   0   0   0 100   0   0   0   0   0   0   0   0   0   0   0 120   0 290   0   0   0   0   0   0   0   0   0   0   0
  0   0   0   0   0   0   0   0   0  90   0   0   0   0   0   0   0   0   0   0   0 290   0 220   0   0   0   0   0   0   0   0   0   0
  0   0   0   0   0   0   0   0   0   0  20   0   0   0   0   0   0   0   0   0   0   0 220   0 160   0   0   0   0   0   0   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0 140   0   0   0   0   0   0   0   0   0   0 160   0  40   0   0   0   0   0   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0 140   0   0   0   0   0   0   0   0   0   0  40   0   0   0   0   0   0   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  60   0   0   0   0   0   0   0   0   0   0 500   0   0   0   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 500   0 100  30   0   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 100   0   0  30 100 999   0
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 150 100   0   0   0   0   0   0   0   0  30   0   0 100   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 100 100   0   0   0   0   0   0   0   0  30 100   0   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 100   0   0   0   0   0   0   0   0 100   0   0   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 999   0   0   0   0   0
  0   0   0   0   0   0   0   0   0   0   0   0   0 150 200   0  50   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

你可能感兴趣的:(#,数据结构,#,数学几何,#,最短路,笔记)