當前位置:編程學習大全網 - 編程語言 - 請教如何運用數據結構理論進行課程規劃設計(希望附上結果)

請教如何運用數據結構理論進行課程規劃設計(希望附上結果)

# include & ltiostream & gt

使用命名空間std

char city name[7][256];

int dis[7][7] = {{-1,100,200,200,-1,-1,-1},

{-1, -1, -1, 50, 150, -1, -1},

{-1, -1, -1, 100, -1, 150, -1},

{-1, -1, -1, -1, 100, 350, -1},

{-1, -1, -1, -1, -1, -1, 150},

{-1, -1, -1, -1, 400, -1, 500},

{-1, -1, -1, -1, -1, -1, -1}};

int from[7];

int disSum[7];

int count,count 1;

int nextNoList[7];

int nextnolist 1[7];

char path[7][256];

炭化溫度[256];

int main()

{

Strcpy(cityName[0],"廣州");

Strcpy(cityName[1],"佛山");

Strcpy(cityName[2],"肇慶");

Strcpy(cityName[3],"珠海");

Strcpy(cityName[4],"深圳");

Strcpy(cityName[5],"南寧");

Strcpy(cityName[6],"香港");

int i,j;

for(I = 0;我& lt7;i++)

{

disSum[I]=-1;

from[I]=-1;

}

count = 1;

nextNoList[0]= 0;

disSum[0]= 0;

strcpy(path[0],city name[0]);

while(計數)

{

count 1 = 0;

for(j = 0;j & lt數數;j++)

{

for(I = 1;我& lt7;i++)

{

if (dis[nextNoList[j]][i]!= -1)

{

if(disSum[I]= =-1 | | disSum[I]>;disSum[next nolist[j]]+dis[nextNoList[j]][I])

{

disSum[I]= disSum[nextNoList[j]]+dis[nextNoList[j]][I];

nextnolist 1[count 1++]= I;

from[I]= nextNoList[j];

strcpy(temp,path[nextNoList[j]]);

strcat(temp,"->);

strcat(temp,city name[I]);

strcpy(path[i],temp);

}

}

}

}

count = count 1;

for(j = 0;j & ltcount 1;j++)

{

next nolist[j]= nextNoList 1[j];

}

}

for(I = 1;我& lt7;i++)

{

Printf("從%s到% s:% d:% s \ n ",cityname [0],cityname [i],dissum [i],path[I]);

}

返回0;

}

  • 上一篇:origin中如何在圖中添加標簽
  • 下一篇:重慶比較好的it培訓機構
  • copyright 2024編程學習大全網