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 |
我用的prim,怎么就错了啊???高手过来看看啊!~#include<stdio.h> void main() { int vl[501][501]; int flag[501],p[501]; int m,n,i,j,min,k=0,g,max; scanf("%d",&n); while(n--) { g=0; max=0; scanf("%d",&m); for(i=0;i<m;i++) for(j=0;j<m;j++) scanf("%d",&vl[i][j]); flag[0]=1; for(i=1;i<m;i++) flag[i]=0; while(g<m-1) { min=65537; i=k; for(j=0;j<m;j++) { if(vl[i][j]<=min&&(flag[j]==0)) { min=vl[i][j]; k=j; } } p[g++]=min; flag[k]=1; } for(i=0;i<g;i++) { if(max<p[i]) max=p[i]; } printf("%d\n",max); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator