Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:求教Floyed RuntimeErr问题In Reply To:求教Floyed RuntimeErr问题 Posted by:supersense at 2009-09-15 15:03:20 > 为什么我的代码老是runtimeerror,诸位指教一下,谢过~ > #include <stdio.h> > #define INT_MAX 200000 > > int cost[100][100]; > int shortest[100][100]; > > void floyed(int n) > { > int i,j,k; > for(i=1;i<=n;i++) > for(j=1;j<=n;j++) > { > shortest[i][j]=cost[i][j]; > } > > for(k=1;k<=n;k++) > for(i=1;i<=n;i++) > for(j=1;j<=n;j++) > { > if(shortest[i][j]>(shortest[i][k]+shortest[k][j])) > { > shortest[i][j]=shortest[i][k]+shortest[k][j]; > } > } > } > > int main() > { > > int i,j,min_max,min,end,temp,n,m,num; > > while(1) > { > for(i=0;i<100;i++) > for(j=0;j<100;j++) > { > if(i==j) > { > cost[i][j]=0; > } > else > { > cost[i][j]=INT_MAX; > } > } > scanf("%d",&num); > > if(num!=0) > { > n=num; > i=1; > while(n) > { > scanf("%d",&m); > while(m) > { > scanf("%d",&j); > scanf("%d",&cost[i][j]); > m--; > } > i++; > n--; > } > floyed(num); > > min=INT_MAX; > for(i=1;i<=num;i++) > { > min_max=0; > for(j=1;j<=num;j++) > { > if(min_max<shortest[i][j]) > { > min_max=shortest[i][j]; > temp=i; > } > } > > if(min>min_max) > { > min=min_max; > end=temp; > } > } > printf("%d %d\n",end,min); > /*for(i=1;i<=num;i++) > { > for(j=1;j<=num;j++) > printf("%d ",shortest[i][j]); > printf("\n"); > }*/ > } > > else > break; > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator