⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inqure.cpp

📁 次界面好用但是也可能有许多不足还希望有贤人志士指点迷津!
💻 CPP
字号:
#include"traffic.h"

step Inqurie(ALGraph G)
 {
   char ch = '0';
   int i ,j ,k=0,n=0,f = -1,t = -1;
   CityName from,to;
   StrARR path;
   extern visited[];
  openfile("head");
  while(f == -1)
  {
   printf("please input Start station:\n");
   scanf("%s",from);
   getchar();
   f = LocateVex(G,from);
   if(f == -1)
    {
     printf("There is not %s station",from);
     n++;
     if(n == MAXERROR)
     {
     printf("    Sorry!\n");
     printf("Maybe you forget the station name.\nplease check careful and reinput!\n");
     return NEXTSTEP;
     }
    }
  }  

   while(t == -1)
   {
     printf("\nplease inpiut the station where you want to arrive!\n");
     scanf("%s",to);
     getchar();
     t = LocateVex(G,to);
   if(t == -1)
    {
     printf("There is not %s station",to);
     n++;
     if(n == MAXERROR)
     {
     printf("    Sorry!\n");
     printf("Maybe you forget the station name.\nplease check careful and reinput!\n");
      return NEXTSTEP;
     }
    }
   }
    while(k == 0)
    {
      printf("which tool do you want to by?\n1  Train  2 fly");
      scanf("%d",&k);
      getchar();
      if(k != 1&& k != 2)
       {
	 printf("input error!!\n");
	  k = 0;
       }
    }
   
 for(i = 0; i< MAX_VERTEX_NUM; i++)
 visited[i] = 0;
 
 for(i = 0 ;i < MAX_VERTEX_NUM ; i++)
  for(j = 0;j <= MAX_VERTEX_NUM ; j++)
 path[i][j] = -1;
 
 n = 0;
 AllPath(G,f,t,path,n);
   
 if(n == 0)
  {
  printf("There is no path from %s,to %s!\n",from,to);
  return OK;
  }
  while(ch == '0')
  {
    openfile("inquire");
    printf("\n   From  %s  to  %s\nwhich scheme do you want to choose?\n",from,to);
        ch = NEXTSTEP;
  switch(ch)
   {
    case '1':
     ch = Shorttime(G,k-1,path,n);break;
    case '2':
    ch = Lessmoney(G,k-1,path,n);break;
    case '3':
    ch = Lesschange(G,k-1,path,n);break;
    case 'i':case 's':case 'e':case 'q':
    break;
    default:ch = '0';
   }
  }
  return ch;
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -