C++实现简单校园导游系统

IT教程2年前 (2022)发布 tang
193 0 0
马哥源码

马哥资源网

这篇文章主要为大家详细介绍了C++实现简单校园导游系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了C++实现校园导游系统的具体代码,供大家参考,具体内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
#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为后台管理的登录密码
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;
//将文本文件打开并输出文件中的内容
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;
}
//查找相应景点的介绍
void FindIntroduction(MGraph &g)
{
  int x,d;
  while(1)
  {
    printf("请输入要查询的景点的编号:");
    scanf("%d",&x);
    ReadData(g);
    printf("景点的名称:%s\n",g.vex[x].name);
    printf("景点的简介:");
    printf("%s\n",g.vex[x].introduction);
    printf("是否要继续查询(0.继续 1.不继续):");
    scanf("%d",&d);
    while(1)
    {
      if(d==0||d==1)
        break;
      else
      {
        printf("输入的数据不合理,请重新输入:");
        scanf("%d",&d);
      }
    }
    if(d==0)
      continue;
    else
      break;
  }
}
//输出两个顶点间的最短路径
void Dispath(MGraph &g,int A[][100],int path[][100])
{
  int i,j,k,s,u,v;
  printf("请输入你所在位置的编号:");
  scanf("%d",&u);
  printf("请输入你要去位置的编号:");
  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(" 路径长度为:%d",A[i][j]);
        printf("\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);
}
//查找两顶点间的所有路径
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;
}
//删除景点简介信息
void delete_str(char str1[], char str2[],int len,char str3[])
{
  int num=0,k=0,i=0,j=0;  //num用来记录子串的个数 k用来记录子串的位置
  char *p=str2;       //使用p还原str到初始位置
  while(str1[i]!='\0')
  {
    if(str1[i]!=str2[j])
    {
      str3[k++]=str1[i++]; //当str1中的字符与str的首字符不相同时
    }
    else
    {
      char *temp=str2;
      for(; (str1[i]==str2[j])&&str2[j]!='\0'; j++)
      {
        i++;
      }
      if(j==len)
      {
        num++;      //出现重复子串,num加一
      }
      else
      {
        //主字符串中存在和子串前几个字符相同的一段字符
        //退出循环并将这段字符写进新的字符数组中
        for(int m=0; m<j; m++)
        {
          str3[k++]=temp[m];
        }
      }
      str2=p;
      j=0;
    }
  }
}
//密码输入函数
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')     //当遇到退格键不做处理
      {
        printf("\b \b");
        i--;
      }
      else
      {
        pass=0;
        break;  //退出for循环后,再次接受
      }
    }
    fflush(stdin); //清除键盘缓存区中已经有的输入
    printf("\n");
    if(pass==0)  //此条件成立可能由两种情况引起:输入了非数字字符被直接重置为0,或6位全0后正常退出for循环
    {
      printf("密码要求全为数字,且不能全0!\n");
      printf("请重新输入密码: ");
    }
    else
      break;
  }
  return pass;
}
//在图中增加一个顶点
void add_point(MGraph &g)
{
  int i,d;
  N++;
  g.vex[N-1].num=N-1;
  printf("%d\n",N);
  printf("请输入要增加景点的名称:");
  scanf("%s",g.vex[N-1].name);
  printf("%s\n",g.vex[N-1].name);
  printf("请输入该景点与其它景点间的路径长度:");
  for(i=0; i<N; i++)
  {
    scanf("%d",&d);
    g.edges[i][N-1]=g.edges[N-1][i]=d;
  }
  printf("请输入要增加顶点的简介:");
  scanf("%s",g.vex[N-1].introduction);
  printf("增加成功!\n");
}
//在图中增加一条路径
void add_path(MGraph &g)
{
  int i,j,length,k;
  do
  {
    printf("请输入要增加路径的起始点的编号:");
    scanf("%d",&i);
    printf("请输入要增加路径的终点的编号:");
    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("该两点之间已存在路径,是否进行修改(0.修改 1.不修改):");
        scanf("%d",&k);
        if(k==0)
        {
          printf("请输入要修改的路径的长度:");
          scanf("%d",&length);
          g.edges[j][i]=g.edges[i][j]=length;
          printf("修改成功!");
        }
        else
          g.edges[j][i]=g.edges[i][j];
      }
      else
      {
        printf("请输入要增加的路径的长度:");
        scanf("%d",&length);
        g.edges[j][i]=g.edges[i][j]=length;
        printf("添加成功!\n");
      }
      break;
    }
    else
    {
      printf("输入的顶点在原图中不存在!\n");
      continue;
    }
  }
  while(1);
}
//删除图中的一个顶点
void delete_point(MGraph &g)
{
  int i,j,m;
  printf("%d\n",N);
  printf("请输入要删除景点的编号:");
  scanf("%d",&m);
  do
  {
    if(m>=0&&m<=N-1)
      break;
    else
    {
      printf("请输入要删除景点的编号:");
      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("请输入要删除路径的起始点的编号:");
    scanf("%d",&i);
    printf("请输入要删除路径的终点的编号:");
    scanf("%d",&j);
    if(g.edges[i][j]==INF)
      printf("这两点间不存在路径!\n");
    else
    {
      g.edges[i][j]=g.edges[j][i]=INF;
      break;
    }
  }
  while(1);
  printf("删除成功!\n");
}
//整个程序的驱动
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.用户        *\n");
  printf("\t\t   *    2.管理人员      *\n");
  printf("\t\t   *******************************\n");
  printf("请选择相应的编号进行下一步操作:");
  scanf("%d",&k);
  do
  {
    if(k==1||k==2)
      break;
    else
    {
      printf("输入数据不合理,请重新输入:");
      scanf("%d",&k);
    }
  }
  while(1);
  if(k==1)
  {
    system("title 校园景点介绍及路径查询系统");
    system("color F0");
    printf("\n\n\n\n\n\n\n\n\n\n\n\n");
    printf("\t\t\t欢迎进入校园景点介绍及路径查询系统!\n\n\n\n\n\n\n\n\n\n\n\n\n");
    printf("正在进入,请稍后...\n");
    printf("===============================================================================\r");
    for(j=0; j<80; j++)
    {
      Sleep(50);
      printf(">");
    }
    system("cls");
    do
    {
      printf("\t\t   *******************************\n");
      printf("\t\t   *    1.景点简介      *\n");
      printf("\t\t   *    2.两景点间最短路径  *\n");
      printf("\t\t   *    3.两景点间所有路径  *\n");
      printf("\t\t   *    4.退出系统      *\n");
      printf("\t\t   *******************************\n");
      printf("请输入要进行的操作的编号:");
      scanf("%d",&x);
      do
      {
        if(x>=1&&x<=4)
          break;
        else
        {
          printf("输入数据不合理,请重新输入:");
          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("是否继续进行该操作(0.继续 1.不继续):");
          scanf("%d",&y);
          if(y==1)
            break;
          else
            continue;
        }
        while(1);
        system("pause");
        system("cls");
        break;
      case 3:
        ReadData(g);
        do
        {
          printf("请输入起点位置的编号:");
          scanf("%d",&u);
          printf("请输入终点位置的编号:");
          scanf("%d",&v);
          printf("从%s到%s的所有路径为:\n",g.vex[u].name,g.vex[v].name);
          FindaPath(g,G,u,v,path,-1);
          printf("是否继续进行该操作(0.继续 1.不继续):");
          scanf("%d",&y);
          if(y==1)
            break;
          else
            continue;
        }
        while(1);
        system("pause");
        system("cls");
        break;
      case 4:
        printf("确认退出吗(0.退出 1.不退出):");
        scanf("%d",&ch);
        while(1)
        {
          if(ch==0||ch==1)
            break;
          else
          {
            printf("输入的数据不合理,请重新输入:");
            scanf("%d",&ch);
          }
        }
        if(ch==0)
        {
          x=0;
          printf("谢谢使用本系统,欢迎下次光临!");
        }
        else
        {
          continue;
        }
      }
    }
    while(x!=0);
  }
  else
  {
    printf("请输入管理代号:");
    scanf("%s",na);
    printf("请输入管理登录密码:");
    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("你已经输错三次密码,系统将于10秒后关闭!");
          Sleep(10000);
          break;
        }
        printf("输入的密码错误!你还有%d次机会,请重新输入:",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.增加景点简介信息   *\n");
        printf("\t\t   *   2.删除景点简介信息   *\n");
        printf("\t\t   *   3.更新景点简介信息   *\n");
        printf("\t\t   *   4.增加景点       *\n");
        printf("\t\t   *   5.增加路径       *\n");
        printf("\t\t   *   6.删除景点       *\n");
        printf("\t\t   *   7.删除路径       *\n");
        printf("\t\t   *   8.退出系统       *\n");
        printf("\t\t   *******************************\n");
        printf("请选择要进行的操作:");
        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("请输入要要增加信息的景点的编号:");
            scanf("%d",&d);
            ReadData(g);
            printf("%s\n",g.vex[d].introduction);
            printf("请输入要增加的信息:");
            scanf("%s",str2);
            strcat(g.vex[d].introduction,str2);
            printf("增加成功!\n");
            WriteData(g);
            printf("是否继续进行该操作(0.继续 1.不继续):");
            scanf("%d",&y);
            if(y==1)
              break;
            else
              continue;
          }
          while(1);
          system("cls");
        }
        if(l==2)
        {
          do
          {
            printf("请输入要删除信息的景点的编号:");
            scanf("%d",&d);
            ReadData(g);
            strcpy(str1,g.vex[d].introduction);
            printf("%s\n",str1);
            printf("请输入要删除的信息:");
            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("是否继续进行该操作(0.继续 1.不继续):");
            scanf("%d",&y);
            if(y==1)
              break;
            else
              continue;
          }
          while(1);
          system("cls");
        }
        if(l==3)
        {
          do
          {
            printf("请输入要更新信息的景点的编号:");
            scanf("%d",&d);
            ReadData(g);
            printf("请输入要更新的信息:");
            scanf("%s",str2);
            strcpy(g.vex[d].introduction,str2);
            WriteData(g);
            printf("是否继续进行该操作(0.继续 1.不继续):");
            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("确认退出吗(0.退出 1.不退出):");
          scanf("%d",&ch);
          while(1)
          {
            if(ch==0||ch==1)
              break;
            else
            {
              printf("输入的数据不合理,请重新输入:");
              scanf("%d",&ch);
            }
          }
          if(ch==0)
          {
            x=0;
            printf("正在退出....");
            Sleep(5000);
            break;
          }
          else
          {
            continue;
          }
        }
      }
      while(1);
    }
  }
}
int main()
{
  function();
  return 0;
}

需要的文件:

C++实现简单校园导游系统

path.txt的内容:

1
2
3
4
5
6
7
8
9
10
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的内容:

1
pass 123456

data.txt的内容:

1
2
3
4
5
6
7
8
9
10
0 三元湖 烟大的一道靓丽的风景
1 钟楼 配备有专业设备的实验综合楼
2 八景园 休息和聊天的好去处
3 小树林 各种社团的活动场所,
4 九龙广场 海豚雕塑加上美丽的喷泉很漂亮
5 八餐 美味的饭菜让人回味无穷
6 一餐 豪华的装修,美味的饭菜
7 体育场 锻炼和饭后散步的好去处
8 七餐 全亚洲最大的学生餐厅
9 新图 藏书丰富,安静的环境让人很舒服

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持源码搜藏网。

© 版权声明

相关文章

暂无评论

暂无评论...