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 |
帮我看看 我的为什么一直wa!谢谢啦!!!#include<stdio.h> #include<string.h> #define max 10000000 #define N 503 int a[N][N],dis[N]; int m,mina; int prim(){ int i,j,k,min; mina=0; for(i=1;i<=m;i++) dis[i]=a[1][i]; for(i=2;i<=m;i++){ min=max; for(j=1;j<=m;j++) if(dis[j]!=0&&dis[j]<min){ min=dis[j]; k=j; } dis[j]=0; if(mina<min)mina=min; for(j=1;j<=m;j++) if(a[k][j]!=0&&a[k][j]<dis[j]) dis[j]=a[k][j]; } printf("%d\n",mina); } int main() { int i,j,t; scanf("%d",&t); while(t--){ scanf("%d",&m); memset(dis,max,sizeof(dis)); for(i=1;i<=m;i++) for(j=1;j<=m;j++) scanf("%d",&a[i][j]); prim(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator