Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我用的prim,怎么就错了啊???高手过来看看啊!~

Posted by ding59 at 2008-10-26 18:18:41 on Problem 2485
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator