creat.cpp

来自「次界面好用但是也可能有许多不足还希望有贤人志士指点迷津!」· C++ 代码 · 共 65 行

CPP
65
字号
void CreatGraph(ALGraph &G)
{
  int i,v1,v2,j;
  ArcNode * p;
  Flytype * f;
  TrainType * t;
   printf("please input the number:");
   scanf("%d %d",&G.vexnum,&G.arcnum);
   printf("please input the city name:");
   for(i = 0;i < G.vexnum;++i)
    {
    printf("\nthe %d city is:",i+1);
     scanf("%s",&G.vertices[i].data);
     G.vertices[i].firstarc=NULL;
    }
    printf("whitch city have line:\n");
   for(i = 0;i < G.arcnum;++ i)
    {
    printf("the %d line\n",i+1);
      scanf("%d %d",&v1,&v2);
      p=(ArcNode *)malloc(sizeof(ArcNode)) ;
	 
      printf("how many train lines?\n");
      scanf("%d",&j);
      if(j > 0)
      {
       t=(TrainType *)malloc(sizeof(TrainType));
       t->line = j;
       printf("how much money this line?\n");
       scanf("%d",&t->money);
       for(j = 0;j < t->line;j++)
        {
         printf("please input the %d line starttime(hour:minute)\n",j);
	 scanf("%d:%d",&t -> starttime[j].hour,&t->starttime[j].minute);

	}
       p -> train = t;
      }
      else
      {
       p -> train =NULL;
       }
      
      printf("how many fly lines?\n");
      scanf("%d",&j);
      if(j > 0)
      {
       f = (Flytype *)malloc(sizeof(Flytype));
       f->line = j;
       printf("how much money this line?\n");
       scanf("%d",&f -> money);
       for(j = 0;j < f -> line;j++)
        {
         printf("please input the %d line starttime(hour:minute)\n",j);
	 scanf("%d:%d",&f -> starttime[j].hour,&f -> starttime[j].minute);
	}
	p -> fly = f;
      }
      p->adjvex = v2;
      p->nextarc = G.vertices[i].firstarc;
      G.vertices[i].firstarc = p;
    }
   }

⌨️ 快捷键说明

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