标签:return void == namespace code floyd blog iostream for
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 #define INF 9999999//将其设定为一个大数 6 #define RANGE 101 7 using namespace std; 8 int d[RANGE][RANGE]; 9 int n,m; 10 void warshall_floyd() 11 { 12 int i,j,k; 13 for(k=1;k<=n;k++) 14 for(i=1;i<=n;i++) 15 for(j=1;j<=n;j++) 16 d[i][j]=min(d[i][j],d[i][k]+d[k][j]); 17 } 18 int main() 19 { 20 int a,b,c,i,j; 21 while(scanf("%d%d",&n,&m)) 22 { 23 if(n==0&&m==0) 24 break; 25 for(i=1;i<=n;i++) 26 for(j=1;j<=i;j++) 27 { 28 if(i==j) 29 d[i][j]=0; 30 else 31 d[i][j]=d[j][i]=INF; 32 } 33 34 for(i=0;i<m;i++) 35 { 36 scanf("%d%d%d",&a,&b,&c); 37 d[a][b]=d[b][a]=c; 38 } 39 warshall_floyd(); 40 printf("%d\n",d[1][n]); 41 } 42 return 0; 43 }
标签:return void == namespace code floyd blog iostream for
原文地址:http://www.cnblogs.com/Emilylice/p/7751366.html