全国交通咨询模拟系统实验报告

页眉内容

//printf(\ist[track[i]].Train[tmp].StartTime`,AdjList[track[i]].Train[tmp].StopTime/60,AdjList[track[i]].Train[tmp].StopTime`);

} } {

{

else

for(i--;i>0;i--)

printf(\ end=track[i-1];min=32767;

for (k=0;k

//这句错了,AdjList[track[i]].Train[k].EndCity改为 /*if

AdjList[track[i]].Flight[k].EndCity!

(AdjList[track[i]].Train[k].EndCity==end&&min>AdjList[track[i]].Flight[k].Cost)

{ */ if

(AdjList[track[i]].Flight[k].EndCity==end&&min>AdjList[track[i]].Flight[k].Cost) 60;

41

{

min=AdjList[track[i]].Flight[k].Cost; tmp=k;

}

printf(\

startH = AdjList[track[i]].Flight[tmp].StartTime / startM = AdjList[track[i]].Flight[tmp].StartTime %

60 ;

页脚内容

页眉内容

endH = AdjList[track[i]].Flight[tmp].StopTime / 60 ; endM = AdjList[track[i]].Flight[tmp].StopTime %

60 ;

if( !(startH/10) ) {

printf(\ }

printf(\ if( !(startM/10) ) {

printf(\ }

printf(\ if( !(endH/10) ) {

printf(\ }

printf(\ if( !(endM/10) ) {

printf(\ }

printf(\

//printf(\60,AdjList[track[i]].Flight[tmp].StartTime 60,AdjList[track[i]].Flight[tmp].StopTime 60,AdjList[track[i]].Flight[tmp].StopTime % 60);

}

}

页脚内容

41

/ % /

页眉内容

printf(\ printf(\ }

(10)找出最小费用路线

void Dijkstra(int matx[Dij_MAXN][Dij_MAXN],int p_start,int p_end,int TravelType) {

int PreCity[Dij_MAXN]; //PreCity[i]==-1,never used; //PreCity>0,the precity of City i int i,j,min,pre,pos; for (i=0;i

{ }

PreCity[i]=-1; PreCity[p_start]=-2; while (PreCity[p_end]==-1)

{

min=-1;

for (i=0;i

{

for (j=0;j

(PreCity[j]==-1&&matx[i][j]>0&&(min<0||matx[i][j]

(11)初始化系统数据: int InitSysData ()

41

}

{ }

pre=i;pos=j;min=matx[i][j];

PreCity[pos]=pre;

}

Dijkstra_Output(matx,PreCity,p_end,TravelType);

页脚内容

页眉内容

{

FILE *fp;int i,j,hour,minute,num,cost; char stmp1[MAX_STRING_NUM]; char stmp2[MAX_STRING_NUM]; char stmp3[MAX_STRING_NUM];

fp=fopen(CityFile,\ if (!fp)

{

printf(\ return -1;

}

fscanf(fp,\ for (i=0;i

{

fscanf(fp,\ AdjList[i].city=i; AdjList[i].TrainNum=0; AdjList[i].FlightNum=0;

}

fclose(fp);

fp=fopen(TrainFile,\ if (!fp)

{

printf(\ return -1;

}

fscanf(fp,\ for (i=0;i

{

fscanf(fp,\ fscanf(fp,\ fscanf(fp,\ j=SeekCity(stmp2);

41

页脚内容

页眉内容

AdjList[j].Train[AdjList[j].TrainNum].EndCity=SeekCity(stmp3);

strcpy(AdjList[j].Train[AdjList[j].TrainNum].name,stmp1); fscanf(fp,\

AdjList[j].Train[AdjList[j].TrainNum].StartTime=hour*60+minute; fscanf(fp,\

AdjList[j].Train[AdjList[j].TrainNum].StopTime=hour*60+minute; fscanf(fp,\

AdjList[j].Train[AdjList[j].TrainNum].Cost=cost; AdjList[j].TrainNum++;

}

fclose(fp);

fp=fopen(FlightFile,\ if (!fp)

{

printf(\ return -1;

}

fscanf(fp,\ for (i=0;i

{

fscanf(fp,\ fscanf(fp,\ fscanf(fp,\ j=SeekCity(stmp2);

AdjList[j].Flight[AdjList[j].FlightNum].EndCity=SeekCity(stmp3);

strcpy(AdjList[j].Flight[AdjList[j].FlightNum].name,stmp1); fscanf(fp,\

AdjList[j].Flight[AdjList[j].FlightNum].StartTime=hour*60+minute; fscanf(fp,\

AdjList[j].Flight[AdjList[j].FlightNum].StopTime=hour*60+minute;

41

页脚内容

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4