• C++实现景区信息管理系统


    景区信息管理系统

    实现了:

    1.1 建立主程序应用菜单选项

    主程序应用菜单选项包含所实现的所有功能,并且对选项采用数字标识进行选择,对其他错误输入可以进行判别,提示输入错误。

    1.2 导游线路图的创建级景区分布图的输出

    用邻接链表存储景点分布图的信息,(带权无向)图的邻接链表。输出景区景点分布图(邻接矩阵)。图中边的权值∞用32767表示。

    1.3  输出导游线路图

    景区旅游信息管理系统中制订旅游景点导游线路策略,首先通过遍历景点,给出一个入口景点,建立一个导游线路图,导游线路图用有向图表示。

    1.4  输出导游线路图中是否有回路

    景区旅游信息管理系统中,创建好导游路线图后,判断该图中是否存在回路。

    1.5 查找及排序

    l  查找功能: 可以根据用户输入的关键字进行景点的查找,关键字可以在景点名称也可以在景点介绍中。查找成功则返回景点的相关简介,如果查找不成功请给予正确提示。

    l  排序功能:按景点欢迎度,景点的岔路数对景点进行排序并打印出来排序顺序。

    1.6  输出两个景点之间最短路径和最短距离

    求出两个景点间的最短路径和最短距离,并且输出道路修建规划图。 算法采用迪杰斯特拉算法。

    1.7   输出道路修建规划图

    道路建设首先要保证能连通所有景点,但又要花最小的代价。

    1.8  输出车辆的进出信息

    1.8.1 具体需求:

    停车场是一个可以停放n辆汽车,且只有一个大门可供汽车进出。汽车在停车场内按车辆到达时间的先后顺序,依次排列,若车场内已停满n辆车,后来的车只能在门外的便道上等候,一旦有车开走,则排在便道上的第一辆车即可开入;当停车场内某辆车要离开时,在它之后进入的车辆必须先退出车场为它让路,待该辆车开出大门外,其它车辆再按原次序进入车场,每辆停放在车场的车在它离开停车场时必须按它停留的时间长短交纳费用。输出每辆车到达后的停车位置(停车场或便道上),以及某辆车离开停车场时应缴纳的费用和它在停车场内停留的时间。

    1.8.2  停车场的管理流程如下:

    A.当车辆要进入停车场时,检查停车场是否已满,如果未满则车辆进入停车场;如果停车场已满,则车辆进入便道等候。

    B.当车辆要求出栈时,先让在它之后进入停车场的车辆退出停车场为它让路,再让该车退出停车场,让路的所有车辆再按其原来进入停车场的次序进入停车场。之后,再检查在便道上是否有车等候,有车则让最先等待的那辆车进入停车场。

    1.8.3 车辆出入清单:

    每一组输入数据包括三个数据项:汽车“到达”或“离去”信息、汽车牌照号码以及到达或离去的时刻。对每一组输入数据进行操作后的输出信息为:若是车辆到达,则输出汽车在停车场内或便道上的停车位置;若是车辆离去,则输出汽车在停车场内停留的时间和应交纳的费用(在便道上停留的时间不收费)。

    1.9

    退出整个程序。

     

    完整代码如下(直接编译可运行):

      1 #include <iostream>
      2 #include <fstream>
      3 #include <time.h> 
      4 #include <stdio.h>
      5 #include <cstring>
      6 #include <iomanip>
      7 #include <stack>
      8 #include <queue>
      9 #define MAX 20
     10 #define MAX2 2
     11 #define INFINITY 32767
     12 int arr1[MAX][MAX];
     13 
     14 using namespace std;
     15 double arr[MAX][MAX];
     16 
     17 class ArcNode {
     18     public:
     19         int adjvex;
     20         ArcNode *nextarc;
     21         double weight;
     22 };
     23 
     24 
     25 class VNode {
     26     public:
     27         string data1;
     28         string data2;
     29         int wel;
     30         bool wc;
     31         bool rest; 
     32         ArcNode *firstarc;
     33 };
     34 
     35 class ALGraph {
     36     public:
     37         VNode *vertices;
     38         int vexnum, arcnum;
     39         ArcNode *arcNode;
     40 };
     41 
     42 class zanlind
     43 {
     44 public:
     45     int number;
     46     int hour;
     47     int minute;
     48 };
     49 
     50 
     51 int LocateVex(ALGraph G, string v) {
     52     int i; 
     53     for(i = 0; v != G.vertices[i].data1 && i < G.vexnum; i++)
     54         ;
     55     if(i >= G.vexnum)
     56         return -1;
     57     return i;
     58 }
     59 
     60 int LocateW(ALGraph G, int wel) {
     61     int i;
     62     for(i = 0; wel != G.vertices[i].wel && i < G.vexnum; i++)
     63         ;
     64     if(i >= G.vexnum)
     65         return -1;
     66     return i;
     67 }
     68 
     69 void CreateUDN(ALGraph &G) {
     70     G.arcNode=new ArcNode[MAX];
     71     G.vertices=new VNode[MAX];
     72     
     73     fstream file("info.txt");
     74     if(file.fail())
     75     {
     76         cout << "error open!" << endl;
     77     }
     78     int  j;
     79     ArcNode *s, *t;
     80     cout<<"请输入顶点数和边数:";
     81     cin>>G.vexnum>>G.arcnum;
     82     int i=0;
     83     cout<<endl;
     84     while(!file.eof()) 
     85     {
     86         file >>G.vertices[i].data1>>G.vertices[i].data2 >> 
     87         G.vertices[i].wel>> G.vertices[i].rest>>G.vertices[i].wc;
     88         G.vertices[i].firstarc = NULL;
     89         i++;
     90     }    
     91     cout<<endl;    
     92     fstream file1("edge.txt");
     93     if(file.fail())
     94     {
     95         cout << "error open!" << endl;
     96     }
     97     while(!file1.eof()) 
     98     {
     99         int weight;
    100         string v1, v2;
    101         file1>>v1>>v2>>weight;
    102         
    103         int i = LocateVex(G, v1);
    104         int j = LocateVex(G, v2);
    105 
    106         s = new ArcNode();
    107         t = new ArcNode();
    108 
    109         s->adjvex = j;
    110         s->nextarc = G.vertices[i].firstarc;
    111         s->weight=weight;
    112         G.vertices[i].firstarc =s;
    113 
    114         t->adjvex = i;
    115         t->nextarc = G.vertices[j].firstarc;
    116         t->weight=weight;
    117         G.vertices[j].firstarc =t;
    118     }
    119     file1.close();
    120     file.close(); 
    121 
    122 }
    123 
    124 
    125 void  PrintAdjList(ALGraph &G) {
    126     cout<<"下面是图的邻接链表输出:" <<endl;
    127     ArcNode *p;
    128     cout<<"  编号 "<<"顶点"<<"   相邻边编号"<<endl;
    129     for(int i = 0; i < G.vexnum; i++) {
    130         cout<<"   "<<i<<"    "<<G.vertices[i].data1;
    131         for(p = G.vertices[i].firstarc; p; p = p->nextarc)
    132             cout<<"--------->"<<p->adjvex;
    133         cout<<endl;
    134     }
    135 
    136 
    137 }
    138 
    139 void OutputGraph(ALGraph G) {
    140     cout<<"下面是图的邻接矩阵输出:"<<endl;
    141     int m1=G.vexnum;
    142     int m2=G.vexnum;
    143 
    144     for(int i=0; i<m1; i++) {
    145         for(int j=0; j<m2; j++) {
    146             arr[i][j]=32767;
    147         }
    148     }
    149 
    150     for(int k=0; k<m1; k++) {
    151         ArcNode *p=G.vertices[k].firstarc;
    152         for(int i2=0; i2<m2; i2++) {
    153             if(k==i2) {
    154                 arr[k][i2]=0;
    155             }
    156             if(p) {
    157                 arr[k][p->adjvex]=p->weight;
    158                 p=p->nextarc;
    159             }
    160 
    161         }
    162     }
    163     cout<<"        ";
    164     for(int n1=0; n1<m1; n1++) {
    165         cout<<setiosflags(ios::left)<<setw(11)<<G.vertices[n1].data1;
    166 
    167     }
    168     cout<<endl;
    169     for(int n2=0; n2<m1; n2++) {
    170         cout<<setiosflags(ios::left)<<setw(10)<<G.vertices[n2].data1;
    171         for(int n3=0; n3<m1; n3++) {
    172             cout<<setiosflags(ios::left)<<setw(10)<<arr[n2][n3];
    173 
    174         }
    175         cout<<endl;
    176 
    177 
    178     }
    179 
    180 
    181 }
    182 
    183 bool visited[MAX];
    184 stack<int> *s=new stack<int>();
    185 
    186 bool isOver(ALGraph G,bool a[MAX]) {
    187     for(int i=0; i<G.vexnum; i++) {
    188         if(a[i]!=1) {
    189             return false;
    190         }
    191     }
    192     return true;
    193 
    194 
    195 }
    196 
    197 void DFSTraverse(ALGraph G)
    198 {
    199     bool sta[20];
    200     int v;
    201     for (v = 0; v<G.vexnum; v++)
    202     {
    203         sta[v] =true;
    204     }
    205      stack<int>status;
    206      int n=0;
    207      int num = -1;
    208      int pk;
    209      ArcNode *e;
    210      cout << G.vertices[0].data1 << "->";
    211      sta[0] =false;
    212      status.push(0);
    213      int aa, bb;
    214      aa = 0;
    215 
    216      while (n < G.vexnum-1){
    217          e = NULL;
    218          num = status.top();
    219          e = G.vertices[num].firstarc;
    220          while (e){
    221              if (sta[e->adjvex] == false){
    222                  e = e->nextarc;
    223              }
    224              else{
    225                  status.push(e->adjvex);
    226                  cout << G.vertices[e->adjvex].data1<<"->";
    227                  aa = e->adjvex;
    228                  sta[e->adjvex] = false;
    229                  n++;
    230                  break;
    231              }
    232                  }
    233          if (e == NULL){
    234              pk = status.top();
    235              bb = pk;
    236              if (aa != bb){
    237                  cout << G.vertices[pk].data1<<"->";
    238              }
    239             
    240              status.pop();
    241          }
    242          if (status.top() == 0){
    243              cout << G.vertices[0].data1 << "->";
    244          }
    245      }
    246      cout << endl;
    247 }
    248 
    249 bool IsEdge(ALGraph G) {
    250     string s1, s2;
    251     cin>>s1>>s2;
    252     int iA=LocateVex(G,s1);
    253     int jA=LocateVex(G,s2);
    254 
    255     ArcNode *p=G.vertices[iA].firstarc;
    256     while(p) {
    257         if(p->adjvex==jA) {
    258             return 1;
    259         } else {
    260             p=p->nextarc;
    261         }
    262     }
    263     return 0;
    264 
    265 
    266 }
    267 
    268 int adjlist[MAX];
    269 void FindInDegree( ALGraph &g) {
    270     int i;
    271     ArcNode *p;
    272     for (i=0; i<g.vexnum; i++)
    273         adjlist[i]=0;
    274     for (i=0; i<g.vexnum; i++) {
    275         p=g.vertices[i].firstarc;
    276         while(p) {
    277             adjlist[p->adjvex]++;
    278             p=p->nextarc;
    279         }
    280     }
    281 }
    282 void JudgeCir(ALGraph G) {
    283     FindInDegree(G);
    284     int count=0;
    285     int Q[MAX];
    286     int front,rear,v;
    287     front=rear=-1;
    288     for(int i=0; i<G.vexnum; i++) {
    289         if((adjlist[i]==0)||(adjlist[i]==1)) {
    290             Q[++rear]=i;
    291             count++;
    292         }
    293     }
    294 
    295     while(front!=rear) {
    296         v=Q[++front];
    297         if(adjlist[v]==1) {
    298             adjlist[v]=-1;
    299             for(int j=0; j<G.vexnum; j++) {
    300                 if(arr[v][j]>0 && arr[v][j]<32767) {
    301                     adjlist[j]--;
    302                     if(adjlist[j]==1) {
    303                         Q[++rear]=j;
    304                         count++;
    305                     }
    306                 }
    307             }
    308         } else {
    309             adjlist[v]=-1;
    310         }
    311     }
    312 
    313     if(count<G.vexnum) {
    314         cout<<"图中有回路"<<endl;
    315     } else
    316         cout<<"图中无回路"<<endl;
    317 }
    318 
    319 int in[MAX];
    320 
    321 void LocateVex2(ALGraph G, string v) {
    322     for(int i = 0;i < MAX; i++)
    323     {
    324         in[i]=10000;
    325     }
    326     for(int i = 0;i < G.vexnum; i++)
    327     {
    328         if(G.vertices[i].data1.find(v)<G.vertices[i].data1.length() ||
    329         G.vertices[i].data2.find(v)<G.vertices[i].data2.length())    
    330         {
    331             in[i]=i;
    332         }
    333     } 
    334 }
    335 
    336 void Search(ALGraph G,string s) {
    337     FindInDegree(G);
    338     LocateVex2(G, s);
    339     for(int i=0;i<G.vexnum;i++)
    340     {
    341         if(in[i]!=10000)
    342         {
    343             cout<<"您所要查询的景点介绍为:"<<endl
    344                 <<endl<<"该景点名字是:"
    345                 <<G.vertices[in[i]].data1
    346                 <<" "<<endl
    347                 <<"该景点介绍为:"<<G.vertices[in[i]].data2<<endl
    348                 <<"该景点欢迎度为:"
    349                 <<G.vertices[in[i]].wel<<endl<<"有无休息区为:"
    350                 <<G.vertices[in[i]].rest
    351                 <<endl<<"有无厕所为:"<<G.vertices[in[i]].wc
    352                 <<endl<<endl;
    353         }
    354 
    355     }
    356 
    357 }
    358 
    359 void SortWel(ALGraph G) {
    360     int ary[G.vexnum];
    361 
    362     for(int i=0; i<G.vexnum; i++) {
    363         ary[i]=G.vertices[i].wel;
    364     }
    365 
    366     int i, j, tmp;
    367     for(i=0; i<G.vexnum; i++) {
    368         tmp = ary[i];
    369         for(j=G.vexnum-1; j>i; j--) {
    370             if(tmp < ary[j]) {
    371                 ary[i] = ary[j];
    372                 ary[j] = tmp;
    373                 tmp = ary[i];
    374             }
    375         }
    376     }
    377 
    378     for(int j=0; j<G.vexnum; j++) {
    379         int m=LocateW(G,ary[j]);
    380         cout<<j+1<<""<<G.vertices[m].data1<<endl;
    381     }
    382 }
    383 
    384 bool isInN(ALGraph G,int a[MAX],int n)
    385 {
    386     for(int i=0;i<G.vexnum;i++)
    387     {
    388         if(a[i]==n)
    389         {
    390             return true;
    391         }
    392     }
    393     return false;
    394 }
    395 
    396 void SortN(ALGraph G) {
    397     int ary[G.vexnum];
    398     int a[G.vexnum];
    399 
    400     for(int j=0; j<G.vexnum; j++) {
    401         a[j]=10000;
    402     }
    403     
    404     FindInDegree(G);
    405     for(int i=0; i<G.vexnum; i++) {
    406         ary[i]=adjlist[i];
    407     }
    408     
    409     int i, j, tmp;
    410     for(i=0; i<G.vexnum; i++) {
    411         tmp = ary[i];
    412         
    413         for(j=G.vexnum-1; j>i; j--) {
    414             if(tmp <= ary[j]) {
    415                 a[i]=j;
    416                 ary[i] = ary[j];
    417                 a[i]=j;
    418                 ary[j] = tmp;
    419                 tmp = ary[i];
    420             }    
    421             
    422             
    423         }
    424     }
    425 
    426     for(int j=0;j<G.vexnum;j++)
    427     {
    428         for(int i=0;i<G.vexnum;i++)
    429         {
    430             if(ary[j]==adjlist[i])
    431             {
    432                 if(!isInN(G,a,i))
    433                 {
    434                     a[j]=i;
    435                 }
    436                 else
    437                 {
    438                     continue;
    439                 }
    440             }
    441         }
    442     }    
    443         for(int i=0;i<G.vexnum;i++)
    444     {
    445         cout<<i+1<<""<<G.vertices[a[i]].data1<<endl;
    446     }
    447 
    448 
    449 }
    450 
    451 void ShortestPath_DIJ(ALGraph G,int v0, int p[][MAX], int D[]) {
    452     int v, w, i, j, min;
    453     bool final[10];
    454     for(v=0; v<G.vexnum; v++) {
    455         final[v]=false;
    456         D[v]=arr[v0][v];
    457         for(w=0; w<G.vexnum; w++)
    458             p[v][w]=-1;
    459         if(D[v]<INFINITY) {
    460             p[v][0]=v0;
    461             p[v][1]=v;
    462         }
    463     }
    464 
    465     D[v0]=0;
    466     final[v0]=true;
    467 
    468     for(i=1; i<G.vexnum; i++) {
    469         min=INFINITY;
    470         for(w=0; w<G.vexnum; w++)
    471             if(!final[w] && D[w]<min) {
    472                 v=w;
    473                 min=D[w];
    474             }
    475         final[v]=true;
    476         for(w=0; w<G.vexnum; w++) {
    477             if(!final[w] && min<INFINITY && arr[v][w]<INFINITY
    478              && (min+arr[v][w]<D[w])) {
    479                 D[w]=min+arr[v][w];
    480                 for(j=0; j<G.vexnum; j++) {
    481                     p[w][j]=p[v][j];
    482                     if(p[w][j]==-1) {
    483                         p[w][j]=w;
    484                         break;
    485                     }
    486                 }
    487 
    488             }
    489         }
    490     }
    491 }
    492 
    493 bool isInVe(ALGraph G,string va)
    494 {
    495     for(int i=0;i<G.vexnum;i++)
    496     {
    497         if(G.vertices[i].data1==va)
    498         {
    499             return true;
    500         }
    501     }
    502     return false;
    503 }
    504 
    505 void printShortestPath(ALGraph G)
    506 {
    507     
    508     int iA,jA;
    509     string s1,s2;
    510     int p[MAX][MAX];
    511     int D[MAX];
    512     cout<<"请输入要查询距离的两个景点的名称:";
    513     cin>>s1>>s2;
    514     if(isInVe(G,s1) && isInVe(G,s2))
    515     {
    516         iA=LocateVex(G,s1);
    517         jA=LocateVex(G,s2);
    518         ShortestPath_DIJ(G,iA, p, D);
    519         cout<<"到各顶点的最短路径及长度为:"<<endl;
    520         
    521         if(jA!=0 && D[jA]!=INFINITY) {
    522             cout<<"最短路径为:";
    523             for(int j=0; j<G.vexnum; j++) {
    524                 if(p[jA][j]>-1)
    525                     cout<<G.vertices[p[jA][j]].data1
    526                         <<" ";
    527                 }
    528                 cout<<endl;
    529                 cout<<"最短距离为:"<<D[jA];
    530         } else if(D[jA]==INFINITY)
    531                     cout<<G.vertices[iA].data1<<"-"
    532                     <<G.vertices[jA].data1
    533                     <<":"<<"不可达"<<endl;    
    534     }
    535     else
    536     {
    537         cout<<"您输入的景点名称不存在,请输入正确的景点名称:"<<endl;
    538         printShortestPath(G);
    539     }
    540 
    541  } 
    542  
    543 void prim(ALGraph G,int v,double arr[MAX][MAX]) {
    544 
    545     int lowcost[MAX];
    546     int min;
    547     int closest[MAX],i,j,k;
    548     for(i=0; i<G.vexnum; i++) {
    549         lowcost[i]=arr[v][i];
    550         closest[i]=v;
    551     }
    552     for(i=1; i<G.vexnum; i++) {
    553         min=INFINITY;
    554         for(j=0; j<G.vexnum; j++) {
    555             if(lowcost[j]!=0&&lowcost[j]<min) {
    556                 min=lowcost[j];
    557                 k=j;
    558             }
    559         }
    560         cout<<""<<G.vertices[closest[k]].data1<<""
    561         <<G.vertices[k].data1<<"修一条路"<<endl;
    562         lowcost[k]=0;
    563 
    564         for(j=0; j<G.vexnum; j++) {
    565             if(arr[k][j]!=0 && arr[k][j]<lowcost[j]) {
    566                 lowcost[j]=arr[k][j];
    567                 closest[j]=k;
    568             }
    569         }
    570 
    571     }
    572 }   
    573    
    574 stack<zanlind> parking;  
    575 stack<zanlind> cars;  
    576 queue<zanlind> waits;
    577 int z[MAX2];
    578 bool isInZan(int zan[],int number)
    579 {
    580     for(int i=0;i<MAX2;i++)
    581     {
    582         if(zan[i]==number)
    583         {
    584             return true;
    585         }
    586     }
    587     return false;
    588 }
    589 
    590 int indexZ(int z[],int n)
    591 {
    592     for(int i=0;i<MAX2;i++)
    593     {
    594         if(z[i]==n)
    595         {
    596             return i;
    597         }
    598     }
    599     return -1;
    600 }
    601 void goIn()
    602 {
    603     int k1=0;
    604     zanlind zan;
    605     cout<<"车牌号为:";
    606     cin>>zan.number;
    607     cout<<endl;
    608     /*
    609     time_t t = time(0);
    610     char tmp[64]; 
    611     strftime(tmp,sizeof(tmp),"%X ",localtime(&t));
    612     zan.time=tmp;
    613     */
    614     struct tm *newtime;
    615     time_t long_time;
    616     time( &long_time ); //Get time as long integer
    617     newtime = localtime( &long_time ); 
    618     int h = newtime->tm_hour;//得到当前时间的小时
    619     int m = newtime->tm_min;//得到当前时间的分钟
    620     zan.hour=h;
    621     zan.minute=m;
    622     
    623     
    624     cout<<"进场时间为:";
    625     if(zan.minute>=1 && zan.minute<10)
    626     {
    627         cout<<zan.hour<<":0"<<zan.minute<<endl;
    628     }
    629     else
    630     {
    631         cout<<zan.hour<<":"<<zan.minute<<endl;
    632     }
    633     
    634     
    635     if(parking.size()<MAX2)
    636     {
    637         for(int m=0;m<MAX2;m++)
    638         {
    639             if(z[m]==0)
    640             {
    641                 z[m]=zan.number;
    642                 break;
    643             }
    644         }
    645         parking.push(zan);
    646         cout<<"该车已进入停车场在: "<<k1++<<"号车道";    
    647     }
    648     else
    649     {
    650         cout<<"停车场已满,请等待其他车辆离开:"; 
    651         waits.push(zan);
    652     }
    653 }
    654 
    655 void goOut()
    656 {
    657     if(parking.size()<=0)
    658     {
    659         cout<<"停车场为空,没有车要离开!";
    660     }
    661     else 
    662     {
    663         cout<<"请输入您的车牌号:";
    664         int number;
    665         cin>>number;
    666         if(isInZan(z,number))
    667         {
    668             while(parking.top().number!=number)
    669             {
    670                 cars.push(parking.top());
    671                 parking.pop();
    672             }
    673             
    674             int num=indexZ(z,parking.top().number);
    675             z[num]=0;
    676             /*
    677             time_t t = time(0);
    678               char tmp[64]; 
    679               strftime(tmp,sizeof(tmp),"%X ",localtime(&t));
    680               */
    681               struct tm *newtime;
    682             time_t long_time;
    683             time( &long_time ); //Get time as long integer
    684             newtime = localtime( &long_time ); 
    685             int h = newtime->tm_hour;//得到当前时间的小时
    686             int m = newtime->tm_min;//得到当前时间的分钟
    687               cout<<"车牌号为:"<<parking.top().number<<"的车要离开了"<<endl
    688               <<"停车时间为: "
    689               <<(h*60+m)-(parking.top().hour*60+parking.top().minute)<<"分钟"<<endl
    690               <<"停车费用为:"
    691               <<((h*60+m)-(parking.top().hour*60+parking.top().minute))*5<<""<<endl; 
    692                   parking.pop();
    693               
    694               while(!cars.empty()) 
    695               {
    696                   parking.push(cars.top());
    697                 cars.pop();    
    698             }
    699             
    700             while(parking.size()<MAX2)
    701             {
    702                 if(waits.size()!=0)
    703                 {    
    704                     for(int m=0;m<MAX2;m++)
    705                     {
    706                         if(z[m]==0)
    707                         {
    708                             z[num]=waits.front().number;
    709                         }
    710                     }
    711                     parking.push(waits.front());        
    712                     waits.pop();
    713                 }
    714                 else
    715                 {
    716                     break;
    717                 }
    718 
    719             } 
    720         }    
    721         
    722         else
    723         {
    724             cout<<"没有该辆车!请输入正确的车牌号:"<<endl;    
    725         }                
    726         
    727     }
    728         
    729 }
    730 
    731 void parkinglot()
    732 {
    733     r2:
    734         cout<<endl<<"            **停车场管理程序**          "<<endl
    735         <<"--------------------------------------------------"<<endl
    736         <<"**"
    737         <<"** A---汽车进车场  D---汽车出车场  E---退出程序 **"<<endl 
    738         <<"--------------------------------------------------"<<endl
    739         <<"请选择:<A ,D ,E>:";
    740         char choose;
    741         cin>>choose;
    742         if(choose=='A' || choose=='D' || choose=='E')
    743         {
    744             switch(choose)
    745             {
    746                 case 'A':
    747                     goIn(); 
    748                     goto r2;
    749                 case 'D':
    750                     goOut();
    751                     goto r2;
    752                 case 'E':
    753                     break;
    754                 }
    755         }
    756         else
    757         {
    758             cout<<"您的输入有误,请输入  <A D E>  其中的一项。";
    759             goto r2;
    760         }
    761 }
    762 
    763 int main() {
    764     int i, j;
    765     int iAA;
    766     ALGraph *G=new ALGraph();
    767     int choose=0;
    768     cout<<endl;
    769     
    770     while(true) {
    771 r:
    772         cout<<"------------------------------------------"<<endl
    773             <<"          欢迎使用景区信息管理系统        "<<endl
    774             <<"              ***请选择菜单***            "<<endl
    775             <<"------------------------------------------"<<endl
    776             <<"   1、创建景区景点分布图                  "<<endl
    777             <<"   2、输出景区景点分布图                  "<<endl
    778             <<"   3、输出导游线路图                      "<<endl
    779             <<"   4、输出导游线路图的回路                "<<endl
    780             <<"   5、查找及排序                          "<<endl
    781             <<"   6、求两个景点间的最短路径和最短距离    "<<endl
    782             <<"   7、输出道路修建规划图                  "<<endl
    783             <<"   8、停车场车辆进出记录信息              "<<endl
    784             <<"   0、退出系统                            "<<endl
    785             <<"请输入您要选择的菜单项: ";
    786             
    787         cin>>choose;
    788         
    789         if(choose<=8 && choose>=0) {
    790             if(choose>1 && G->vexnum==0 &&choose!=8) {
    791                 cout<<endl<<"************您的图为空,请先创建您的图**********:"
    792                 <<endl<<endl;
    793                 goto r;
    794             } else {
    795                 switch(choose) {
    796 
    797                     case 1:
    798                         CreateUDN(*G);
    799 
    800                         break;
    801                     case 2:
    802                         PrintAdjList(*G);
    803                         cout<<endl;
    804                         OutputGraph(*G);
    805                         break;
    806                     case 3:
    807                         cout<<"导游路线为:";
    808                         //CreatTourSortGraph(*G);
    809                         //DFSTraverse(*G);
    810                         break;
    811                     case 4:
    812                         JudgeCir(*G);
    813                         break;
    814                     case 5:
    815                         
    816                     while(true)
    817                     {
    818                         int ch;
    819                         cout<<"您需要"
    820                             <<"  查找(0),"
    821                             <<"按欢迎度排序(1),"
    822                             <<"按景点岔路数排序(2),"
    823                             <<"退出此目录(3) :" ;
    824                         cin>>ch;
    825                         string sA;
    826                         switch(ch)
    827                         {
    828                             case 0:
    829                                 cout<<"请输入您要查找的有关景点的关键字:" ;
    830                                 cin>>sA;
    831                                 Search(*G,sA);
    832                                 break;
    833                             case 1:
    834                                 SortWel(*G);
    835                                 break;
    836                             case 2:
    837                                 SortN(*G);
    838                                 break;
    839                             case 3:
    840                                 goto r;
    841                             default :
    842                                 cout<<"您的输入有误,请重新输入:"<<endl;
    843                         }
    844                     }
    845                     case 6:    
    846                         printShortestPath(*G);
    847                         break;
    848                     case 7:
    849                         prim(*G,0,arr);
    850                         break;
    851                     case 8:
    852                         parkinglot();
    853                         break;
    854                     case 0:
    855                         exit(0);
    856                 }
    857 
    858             }
    859             cout<<endl;
    860         }
    861         else {
    862             cout<<"您的输入有误,请重新输入0-8之间的数字"<<endl;
    863 
    864         }
    865 
    866 
    867     }
    868     return 0;
    869 }
    870  

    所需要的两个edge.txt和info.txt文件。(很重要、一定要有!!!)

     

  • 相关阅读:
    MySQL Explain优化
    mysql联合索引
    MySQL索引类型
    php常用的排序算法与二分法查找
    mysql 主从复制(mysql双机热备的实现)
    mysql 主从复制 (2)
    Linux 查看进程之PS命令
    PHP isset 和 array_key_exists 对比
    Linux md5sum 的用法
    Linux Sphinx 安装与使用
  • 原文地址:https://www.cnblogs.com/yjd_hycf_space/p/6667193.html
Copyright © 2020-2023  润新知