溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

如何使用C++實(shí)現(xiàn)簡(jiǎn)單校園導(dǎo)游系統(tǒng)

發(fā)布時(shí)間:2022-03-17 15:05:22 來(lái)源:億速云 閱讀:95 作者:小新 欄目:開(kāi)發(fā)技術(shù)

小編給大家分享一下如何使用C++實(shí)現(xiàn)簡(jiǎn)單校園導(dǎo)游系統(tǒng),相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

具體內(nèi)容如下

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#define INF 32767
int visited[100],password;  //password為后臺(tái)管理的登錄密碼
FILE *fp;
char na[100];
char str1[100],str3[100];
int N,M;
int a[100][100];
using namespace std;
typedef struct
{
    int num;
    char name[100];
    char introduction[100];
} VertexType;
typedef struct
{
    int edges[100][100];
    int n,e;
    VertexType vex[100];
} MGraph;
typedef struct ANode
{
    int adjvex;
    struct ANode *nextarc;
} ArcNode;
typedef struct Vnode
{
    ArcNode *firstarc;
} VNode;
typedef VNode AdjList[100];
typedef struct
{
    AdjList adjlist;
    int n,e;
} ALGraph;
MGraph g;
//將文本文件打開(kāi)并輸出文件中的內(nèi)容
void ReadData1(MGraph &g)
{
    M=N;
    FILE *fp;
    int i = 0,j;
    if ((fp=fopen("path.txt", "r"))==NULL)
    {
        printf("error open!");
        exit(0);
    }
    for(i=0; i<M; i++)
    {
        for(j=0; j<M; j++)
        {
            fscanf(fp,"%d",&g.edges[i][j]);
        }
    }
    fclose(fp);
}
void WriteData1(MGraph &g)
{
    FILE *fp;
    int i = 0,j;
    if ((fp=fopen("path.txt", "w"))==NULL)
    {
        printf("error open!");
        exit(0);
    }
    for(i=0; i<N; i++)
    {
        for(j=0; j<N; j++)
        {
            printf("%d ",g.edges[i][j]);
            fprintf(fp,"%d ",g.edges[i][j]);
        }
        fprintf(fp,"\n");
        printf("\n");
    }
    fclose(fp);
}
void ReadData(MGraph &g)
{
    FILE *fp;
    int i = 0;
    if ((fp=fopen("data.txt", "r"))==NULL)
    {
        printf("error open!");
        exit(0);
    }
    while(fscanf(fp,"%d %s %s",&g.vex[i].num,g.vex[i].name,g.vex[i].introduction)!= EOF)
    {
        i++;
    }
    N = i;
    fclose(fp);
    return;
}
void WriteData(MGraph &g)
{
    FILE *fp;
    int i=0;
    if ((fp=fopen("data.txt", "w"))==NULL)
    {
        printf("error open!");
        exit(0);
    }
    for(i=0; i<N; i++)
        fprintf(fp,"%d %s %s\n",g.vex[i].num,g.vex[i].name,g.vex[i].introduction);
    fclose(fp);
}
//將鄰接矩陣改為鄰接表
void MatToList(MGraph g,ALGraph *&G)
{
    int i,j;
    ArcNode *p;
    G=(ALGraph *)malloc(sizeof(ALGraph));
    for(i=0; i<g.n; i++)
        G->adjlist[i].firstarc=NULL;
    for(i=0; i<g.n; i++)
        for(j=g.n-1; j>=0; j--)
        {
            if(g.edges[i][j]!=INF)
            {
                p=(ArcNode *)malloc(sizeof(ArcNode));
                p->adjvex=j;
                p->nextarc=G->adjlist[i].firstarc;
                G->adjlist[i].firstarc=p;
            }
        }
    G->n=g.n;
    G->e=g.e;
}
//查找相應(yīng)景點(diǎn)的介紹
void FindIntroduction(MGraph &g)
{
    int x,d;
    while(1)
    {
        printf("請(qǐng)輸入要查詢(xún)的景點(diǎn)的編號(hào):");
        scanf("%d",&x);
        ReadData(g);
        printf("景點(diǎn)的名稱(chēng):%s\n",g.vex[x].name);
        printf("景點(diǎn)的簡(jiǎn)介:");
        printf("%s\n",g.vex[x].introduction);
        printf("是否要繼續(xù)查詢(xún)(0.繼續(xù)  1.不繼續(xù)):");
        scanf("%d",&d);
        while(1)
        {
            if(d==0||d==1)
                break;
            else
            {
                printf("輸入的數(shù)據(jù)不合理,請(qǐng)重新輸入:");
                scanf("%d",&d);
            }
        }
        if(d==0)
            continue;
        else
            break;
    }
}
//輸出兩個(gè)頂點(diǎn)間的最短路徑
void Dispath(MGraph &g,int A[][100],int path[][100])
{
    int i,j,k,s,u,v;
    printf("請(qǐng)輸入你所在位置的編號(hào):");
    scanf("%d",&u);
    printf("請(qǐng)輸入你要去位置的編號(hào):");
    scanf("%d",&v);
    int apath[100],d;
    for(i=0; i<g.n; i++)
    {
        for(j=0; j<g.n; j++)
        {
            if(A[i][j]!=INF&&i!=j&&u==i&&v==j)
            {
                printf("  從%s到%s的最短路徑為:",g.vex[i].name,g.vex[j].name);
                k=path[i][j];
                d=0;
                apath[d]=j;
                while(k!=-1&&k!=i)
                {
                    d++;
                    apath[d]=k;
                    k=path[i][k];
                }
                d++;
                apath[d]=i;
                printf("%s",g.vex[apath[d]].name);
                for(s=d-1; s>=0; s--)
                    printf("->%s",g.vex[apath[s]].name);
                printf("\n");
                printf("  路徑長(zhǎng)度為:%d",A[i][j]);
                printf("\n");
            }
        }
    }
}
//查找兩頂點(diǎn)間的最短路徑
void FindMinPath(MGraph &g)
{
    int A[100][100],path[100][100];
    int i,j,k;
    for(i=0; i<g.n; i++)
    {
        for(j=0; j<g.n; j++)
        {
            A[i][j]=g.edges[i][j];
            if(i!=j&&g.edges[i][j]<INF)
                path[i][j]=i;
            else
                path[i][j]=-1;
        }
    }
    for(k=0; k<g.n; k++)
    {
        for(i=0; i<g.n; i++)
        {
            for(j=0; j<g.n; j++)
            {
                if(A[i][j]>A[k][j]+A[i][k])
                {
                    A[i][j]=A[k][j]+A[i][k];
                    path[i][j]=path[k][j];
                }
            }
        }
    }
    Dispath(g,A,path);
}
//查找兩頂點(diǎn)間的所有路徑
void FindaPath(MGraph &g,ALGraph *G,int u,int v,int path[],int d)
{
    int w,i;
    ArcNode *p;
    visited[u]=1;
    d++;
    path[d]=u;
    if(u==v&&d>=1)
    {
        printf(" ");
        for(i=0; i<d; i++)
            printf("%s->",g.vex[path[i]].name);
        printf("%s",g.vex[path[d]].name);
        printf("\n");
    }
    p=G->adjlist[u].firstarc;
    while(p!=NULL)
    {
        w=p->adjvex;
        if(visited[w]==0)
            FindaPath(g,G,w,v,path,d);
        p=p->nextarc;
    }
    visited[u]=0;
}
//刪除景點(diǎn)簡(jiǎn)介信息
void delete_str(char str1[], char str2[],int len,char str3[])
{
    int num=0,k=0,i=0,j=0;   //num用來(lái)記錄子串的個(gè)數(shù) k用來(lái)記錄子串的位置
    char *p=str2;             //使用p還原str到初始位置
    while(str1[i]!='\0')
    {
        if(str1[i]!=str2[j])
        {
            str3[k++]=str1[i++];  //當(dāng)str1中的字符與str的首字符不相同時(shí)
        }
        else
        {
            char *temp=str2;
            for(; (str1[i]==str2[j])&&str2[j]!='\0'; j++)
            {
                i++;
            }
            if(j==len)
            {
                num++;           //出現(xiàn)重復(fù)子串,num加一
            }
            else
            {
                //主字符串中存在和子串前幾個(gè)字符相同的一段字符
                //退出循環(huán)并將這段字符寫(xiě)進(jìn)新的字符數(shù)組中
                for(int m=0; m<j; m++)
                {
                    str3[k++]=temp[m];
                }
            }
            str2=p;
            j=0;
        }
    }
}
//密碼輸入函數(shù)
int inputpassword()
{
    char a[10];
    int pass=0;
    int i;
    while(1)
    {
        for(i=0; i<6; i++)
        {
            a[i]=getch();
            putchar('*');
            if(a[i]>='0'&&a[i]<='9')
                pass=pass*10+a[i]-'0';
            else if(a[i]=='\b')         //當(dāng)遇到退格鍵不做處理
            {
                printf("\b \b");
                i--;
            }
            else
            {
                pass=0;
                break;   //退出for循環(huán)后,再次接受
            }
        }
        fflush(stdin);  //清除鍵盤(pán)緩存區(qū)中已經(jīng)有的輸入
        printf("\n");
        if(pass==0)    //此條件成立可能由兩種情況引起:輸入了非數(shù)字字符被直接重置為0,或6位全0后正常退出for循環(huán)
        {
            printf("密碼要求全為數(shù)字,且不能全0!\n");
            printf("請(qǐng)重新輸入密碼: ");
        }
        else
            break;
    }
    return pass;
}
//在圖中增加一個(gè)頂點(diǎn)
void add_point(MGraph &g)
{
    int i,d;
    N++;
    g.vex[N-1].num=N-1;
    printf("%d\n",N);
    printf("請(qǐng)輸入要增加景點(diǎn)的名稱(chēng):");
    scanf("%s",g.vex[N-1].name);
    printf("%s\n",g.vex[N-1].name);
    printf("請(qǐng)輸入該景點(diǎn)與其它景點(diǎn)間的路徑長(zhǎng)度:");
    for(i=0; i<N; i++)
    {
        scanf("%d",&d);
        g.edges[i][N-1]=g.edges[N-1][i]=d;
    }
    printf("請(qǐng)輸入要增加頂點(diǎn)的簡(jiǎn)介:");
    scanf("%s",g.vex[N-1].introduction);
    printf("增加成功!\n");
}
//在圖中增加一條路徑
void add_path(MGraph &g)
{
    int i,j,length,k;
    do
    {
        printf("請(qǐng)輸入要增加路徑的起始點(diǎn)的編號(hào):");
        scanf("%d",&i);
        printf("請(qǐng)輸入要增加路徑的終點(diǎn)的編號(hào):");
        scanf("%d",&j);
        if(i>=0&&i<=N-1&&j>=0&&j<=N-1&&j>=0)
        {
            if(g.edges[i][j]!=INF&&g.edges[j][i]!=INF)
            {
                printf("該兩點(diǎn)之間已存在路徑,是否進(jìn)行修改(0.修改 1.不修改):");
                scanf("%d",&k);
                if(k==0)
                {
                    printf("請(qǐng)輸入要修改的路徑的長(zhǎng)度:");
                    scanf("%d",&length);
                    g.edges[j][i]=g.edges[i][j]=length;
                    printf("修改成功!");
                }
                else
                    g.edges[j][i]=g.edges[i][j];
            }
            else
            {
                printf("請(qǐng)輸入要增加的路徑的長(zhǎng)度:");
                scanf("%d",&length);
                g.edges[j][i]=g.edges[i][j]=length;
                printf("添加成功!\n");
            }
            break;
        }
        else
        {
            printf("輸入的頂點(diǎn)在原圖中不存在!\n");
            continue;
        }
    }
    while(1);
}
//刪除圖中的一個(gè)頂點(diǎn)
void delete_point(MGraph &g)
{
    int i,j,m;
    printf("%d\n",N);
    printf("請(qǐng)輸入要?jiǎng)h除景點(diǎn)的編號(hào):");
    scanf("%d",&m);
    do
    {
        if(m>=0&&m<=N-1)
            break;
        else
        {
            printf("請(qǐng)輸入要?jiǎng)h除景點(diǎn)的編號(hào):");
            scanf("%d",&m);
        }
    }
    while(1);
    for(i=0; i<M; i++)
    {
        for(j=0; j<M; j++)
        {
            if(g.edges[m][j]!=INF&&g.edges[i][m]!=INF)
                g.edges[m][j]=g.edges[i][m]=INF;
        }
    }
    g.vex[m].num=INF;
    strcpy(g.vex[m].name,"F");
    printf("刪除成功!\n");
}
//刪除圖中的一條路徑
void delete_path(MGraph &g)
{
    int i,j;
    do
    {
        printf("請(qǐng)輸入要?jiǎng)h除路徑的起始點(diǎn)的編號(hào):");
        scanf("%d",&i);
        printf("請(qǐng)輸入要?jiǎng)h除路徑的終點(diǎn)的編號(hào):");
        scanf("%d",&j);
        if(g.edges[i][j]==INF)
            printf("這兩點(diǎn)間不存在路徑!\n");
        else
        {
            g.edges[i][j]=g.edges[j][i]=INF;
            break;
        }
    }
    while(1);
    printf("刪除成功!\n");
}
//整個(gè)程序的驅(qū)動(dòng)
void function()
{
    ALGraph *G;
    int i,j,u,v,path[100],x,k,l,d,y;
    int ch,pass;
    char str2[500],nam[100];
    g.n=10;
    g.e=18;
    ReadData(g);
    ReadData1(g);
    MatToList(g,G);
    for(i=0; i<G->n; i++)
        visited[i]=0;
    system("color F0");
    printf("\t\t     *******************************\n");
    printf("\t\t     *       1.用戶(hù)                *\n");
    printf("\t\t     *       2.管理人員            *\n");
    printf("\t\t     *******************************\n");
    printf("請(qǐng)選擇相應(yīng)的編號(hào)進(jìn)行下一步操作:");
    scanf("%d",&k);
    do
    {
        if(k==1||k==2)
            break;
        else
        {
            printf("輸入數(shù)據(jù)不合理,請(qǐng)重新輸入:");
            scanf("%d",&k);
        }
    }
    while(1);
    if(k==1)
    {
        system("title 校園景點(diǎn)介紹及路徑查詢(xún)系統(tǒng)");
        system("color F0");
        printf("\n\n\n\n\n\n\n\n\n\n\n\n");
        printf("\t\t\t歡迎進(jìn)入校園景點(diǎn)介紹及路徑查詢(xún)系統(tǒng)!\n\n\n\n\n\n\n\n\n\n\n\n\n");
        printf("正在進(jìn)入,請(qǐng)稍后...\n");
        printf("===============================================================================\r");
        for(j=0; j<80; j++)
        {
            Sleep(50);
            printf(">");
        }
        system("cls");
        do
        {
            printf("\t\t     *******************************\n");
            printf("\t\t     *       1.景點(diǎn)簡(jiǎn)介            *\n");
            printf("\t\t     *       2.兩景點(diǎn)間最短路徑    *\n");
            printf("\t\t     *       3.兩景點(diǎn)間所有路徑    *\n");
            printf("\t\t     *       4.退出系統(tǒng)            *\n");
            printf("\t\t     *******************************\n");
            printf("請(qǐng)輸入要進(jìn)行的操作的編號(hào):");
            scanf("%d",&x);
            do
            {
                if(x>=1&&x<=4)
                    break;
                else
                {
                    printf("輸入數(shù)據(jù)不合理,請(qǐng)重新輸入:");
                    scanf("%d",&x);
                }
            }
            while(1);
            if(x>=1&&x<=3)
            {
                printf("\t\t     *******************************\n");
                if(N%2!=0)
                {
                    for(i=0; i<N-1; i+=2)
                    {
                         printf("\t\t          %d.%s  \t%d.%s  \n",g.vex[i].num,g.vex[i].name,g.vex[i+1].num,g.vex[i+1].name);
                    }
                     printf("\t\t          %d.%s       \n",g.vex[i].num,g.vex[i+1].name);
 
                }
                else
                {
                    for(i=0; i<N; i+=2)
                    {
                         printf("\t\t          %d.%s  \t%d.%s  \n",g.vex[i].num,g.vex[i].name,g.vex[i+1].num,g.vex[i+1].name);
                    }
                }
 
                printf("\t\t     *******************************\n");
                printf("%d",11);
            }
 
            switch(x)
            {
            case 1:
                ReadData(g);
                FindIntroduction(g);
                system("cls");
                break;
            case 2:
                ReadData(g);
                do
                {
                    FindMinPath(g);
                    printf("是否繼續(xù)進(jìn)行該操作(0.繼續(xù) 1.不繼續(xù)):");
                    scanf("%d",&y);
                    if(y==1)
                        break;
                    else
                        continue;
                }
                while(1);
                system("pause");
                system("cls");
                break;
            case 3:
                ReadData(g);
                do
                {
                    printf("請(qǐng)輸入起點(diǎn)位置的編號(hào):");
                    scanf("%d",&u);
                    printf("請(qǐng)輸入終點(diǎn)位置的編號(hào):");
                    scanf("%d",&v);
                    printf("從%s到%s的所有路徑為:\n",g.vex[u].name,g.vex[v].name);
                    FindaPath(g,G,u,v,path,-1);
                    printf("是否繼續(xù)進(jìn)行該操作(0.繼續(xù) 1.不繼續(xù)):");
                    scanf("%d",&y);
                    if(y==1)
                        break;
                    else
                        continue;
                }
                while(1);
                system("pause");
                system("cls");
                break;
            case 4:
                printf("確認(rèn)退出嗎?(0.退出 1.不退出):");
                scanf("%d",&ch);
                while(1)
                {
                    if(ch==0||ch==1)
                        break;
                    else
                    {
                        printf("輸入的數(shù)據(jù)不合理,請(qǐng)重新輸入:");
                        scanf("%d",&ch);
                    }
                }
                if(ch==0)
                {
                    x=0;
                    printf("謝謝使用本系統(tǒng),歡迎下次光臨!");
                }
                else
                {
                    continue;
                }
            }
        }
        while(x!=0);
    }
    else
    {
        printf("請(qǐng)輸入管理代號(hào):");
        scanf("%s",na);
        printf("請(qǐng)輸入管理登錄密碼:");
        password=inputpassword();
        FILE *fp1;
        if((fp1=fopen("password.txt","r"))==NULL)
        {
            printf("Cannot open the file!");
            exit(0);
        }
        fscanf(fp1,"%s %d",nam,&pass);
        fclose(fp1);
        int t=3;
        do
        {
            if(password!=pass)
            {
                t--;
                if(t==0)
                {
                    printf("你已經(jīng)輸錯(cuò)三次密碼,系統(tǒng)將于10秒后關(guān)閉!");
                    Sleep(10000);
                    break;
                }
                printf("輸入的密碼錯(cuò)誤!你還有%d次機(jī)會(huì),請(qǐng)重新輸入:",t);
                password=inputpassword();
            }
            else
                break;
        }
        while(t!=0);
        system("cls");
        if(password==pass&&strcmp(nam,na)==0)
        {
            do
            {
                printf("\t\t     *******************************\n");
                printf("\t\t     *     1.增加景點(diǎn)簡(jiǎn)介信息      *\n");
                printf("\t\t     *     2.刪除景點(diǎn)簡(jiǎn)介信息      *\n");
                printf("\t\t     *     3.更新景點(diǎn)簡(jiǎn)介信息      *\n");
                printf("\t\t     *     4.增加景點(diǎn)              *\n");
                printf("\t\t     *     5.增加路徑              *\n");
                printf("\t\t     *     6.刪除景點(diǎn)              *\n");
                printf("\t\t     *     7.刪除路徑              *\n");
                printf("\t\t     *     8.退出系統(tǒng)              *\n");
                printf("\t\t     *******************************\n");
                printf("請(qǐng)選擇要進(jìn)行的操作:");
                scanf("%d",&l);
                printf("\t\t     *******************************\n");
                if(N%2!=0)
                {
                    for(i=0; i<N-1; i+=2)
                    {
                         printf("\t\t          %d.%s  \t%d.%s  \n",g.vex[i].num,g.vex[i].name,g.vex[i+1].num,g.vex[i+1].name);
                    }
                     printf("\t\t          %d.%s       \n",g.vex[i].num,g.vex[i].name);
 
                }
                else
                {
                    for(i=0; i<N; i+=2)
                    {
                         printf("\t\t          %d.%s  \t%d.%s  \n",g.vex[i].num,g.vex[i].name,g.vex[i+1].num,g.vex[i+1].name);
                    }
                }
                printf("\t\t     *******************************\n");
                if(l==1)
                {
                    do
                    {
                        printf("請(qǐng)輸入要要增加信息的景點(diǎn)的編號(hào):");
                        scanf("%d",&d);
                        ReadData(g);
                        printf("%s\n",g.vex[d].introduction);
                        printf("請(qǐng)輸入要增加的信息:");
                        scanf("%s",str2);
                        strcat(g.vex[d].introduction,str2);
                        printf("增加成功!\n");
                        WriteData(g);
                        printf("是否繼續(xù)進(jìn)行該操作(0.繼續(xù) 1.不繼續(xù)):");
                        scanf("%d",&y);
                        if(y==1)
                            break;
                        else
                            continue;
                    }
                    while(1);
                    system("cls");
                }
                if(l==2)
                {
                    do
                    {
                        printf("請(qǐng)輸入要?jiǎng)h除信息的景點(diǎn)的編號(hào):");
                        scanf("%d",&d);
                        ReadData(g);
                        strcpy(str1,g.vex[d].introduction);
                        printf("%s\n",str1);
                        printf("請(qǐng)輸入要?jiǎng)h除的信息:");
                        scanf("%s",str2);
                        printf("%d\n",N);
                        delete_str(str1,str2,strlen(str2),str3);
                        printf("%s\n",str3);
                        strcpy(g.vex[d].introduction,str3);
                        printf("%s\n",g.vex[d].introduction);
                        WriteData(g);
                        printf("刪除成功!\n");
                        printf("是否繼續(xù)進(jìn)行該操作(0.繼續(xù) 1.不繼續(xù)):");
                        scanf("%d",&y);
                        if(y==1)
                            break;
                        else
                            continue;
                    }
                    while(1);
                    system("cls");
                }
                if(l==3)
                {
                    do
                    {
                        printf("請(qǐng)輸入要更新信息的景點(diǎn)的編號(hào):");
                        scanf("%d",&d);
                        ReadData(g);
                        printf("請(qǐng)輸入要更新的信息:");
                        scanf("%s",str2);
                        strcpy(g.vex[d].introduction,str2);
                        WriteData(g);
                        printf("是否繼續(xù)進(jìn)行該操作(0.繼續(xù) 1.不繼續(xù)):");
                        scanf("%d",&y);
                        if(y==1)
                            break;
                        else
                            continue;
                    }
                    while(1);
                    system("cls");
                }
                if(l==4)
                {
                    ReadData(g);
                    ReadData1(g);
                    for(i=0; i<N; i++)
                    {
                        for(j=0; j<N; j++)
                        {
                            printf("%d ",g.edges[i][j]);
                        }
                        printf("\n");
                    }
                    add_point(g);
                    WriteData1(g);
                    WriteData(g);
                }
                if(l==5)
                {
                    ReadData1(g);
                    for(i=0; i<M; i++)
                    {
                        for(j=0; j<M; j++)
                        {
                            printf("%d ",g.edges[i][j]);
                        }
                        printf("\n");
                    }
                    add_path(g);
                    WriteData1(g);
                }
                if(l==6)
                {
                    ReadData(g);
                    ReadData1(g);
                    for(i=0; i<M; i++)
                    {
                        for(j=0; j<M; j++)
                        {
                            printf("%d ",g.edges[i][j]);
                        }
                        printf("\n");
                    }
                    delete_point(g);
                    WriteData1(g);
                    WriteData(g);
                }
                if(l==7)
                {
                    ReadData1(g);
                    for(i=0; i<M; i++)
                    {
                        for(j=0; j<M; j++)
                        {
                            printf("%d ",g.edges[i][j]);
                        }
                        printf("\n");
                    }
                    delete_path(g);
                    WriteData1(g);
                }
                if(l==8)
                {
                    printf("確認(rèn)退出嗎?(0.退出 1.不退出):");
                    scanf("%d",&ch);
                    while(1)
                    {
                        if(ch==0||ch==1)
                            break;
                        else
                        {
                            printf("輸入的數(shù)據(jù)不合理,請(qǐng)重新輸入:");
                            scanf("%d",&ch);
                        }
                    }
                    if(ch==0)
                    {
                        x=0;
                        printf("正在退出....");
                        Sleep(5000);
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            while(1);
        }
    }
}
int main()
{
    function();
    return 0;
}

需要的文件:

如何使用C++實(shí)現(xiàn)簡(jiǎn)單校園導(dǎo)游系統(tǒng)

path.txt的內(nèi)容:

0 20 60 150 32767 60 32767 100 300 150 
20 0 50 100 32767 32767 32767 32767 32767 32767 
60 50 0 32767 32767 300 40 32767 32767 32767 
150 100 32767 0 32767 32767 32767 100 32767 32767 
32767 32767 32767 32767 0 50 32767 32767 32767 30 
60 32767 300 32767 32767 0 200 32767 32767 50 
32767 32767 40 32767 32767 200 0 32767 32767 32767
100 32767 100 32767 32767 32767 0 50 32767 32767 
300 32767 32767 32767 32767 32767 32767 50 0 350
50 32767 32767 32767 30 50 32767 32767 350

password.txt的內(nèi)容:

pass 123456

data.txt的內(nèi)容:

0 三元湖 煙大的一道靚麗的風(fēng)景
1 鐘樓 配備有專(zhuān)業(yè)設(shè)備的實(shí)驗(yàn)綜合樓
2 八景園 休息和聊天的好去處
3 小樹(shù)林 各種社團(tuán)的活動(dòng)場(chǎng)所,
4 九龍廣場(chǎng) 海豚雕塑加上美麗的噴泉很漂亮
5 八餐 美味的飯菜讓人回味無(wú)窮
6 一餐 豪華的裝修,美味的飯菜
7 體育場(chǎng) 鍛煉和飯后散步的好去處
8 七餐 全亞洲最大的學(xué)生餐廳
9 新圖 藏書(shū)豐富,安靜的環(huán)境讓人很舒服

以上是“如何使用C++實(shí)現(xiàn)簡(jiǎn)單校園導(dǎo)游系統(tǒng)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

c++
AI