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

为什么老是wa啊,又不是很难?

Posted by ass at 2003-12-23 15:34:32 on Problem 1046
#include "math.h"
#include "stdio.h"
void main()
{
	int a[16][3],i,x,y,z,t=0,min;
	for (i=0;i<16;i++)
	{
		scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
	}
	do 
	{
		scanf("%d %d %d",&x,&y,&z);
		min=(x-a[0][0])*(x-a[0][0])+(y-a[0][1])*(y-a[0][1])+(z-a[0][2])*(z-a[0][2]);
		t=0;
		for (i=1;i<16;i++)
		{
			if ((x-a[i][0])*(x-a[i][0])+(y-a[i][1])*(y-a[i][1])+(z-a[i][2])*(z-a[i][2])<=min)
			{
 				min=(x-a[i][0])*(x-a[i][0])+(y-a[i][1])*(y-a[i][1])+(z-a[i][2])*(z-a[i][2]);
				t=i;
			}
		}
		if (x!=-1&&y!=-1&&z!=-1) printf("(%d,%d,%d) maps to (%d,%d,%d)\n",x,y,z,a[t][0],a[t][1],a[t][2]);
	}
	while (x!=-1&&y!=-1&&z!=-1);
}

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