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 fhyvenus at 2008-07-23 10:46:21 on Problem 1046
#include <stdio.h>
#include <math.h>
int main()
{
	int a[20]={0},b[20]={0},c[20]={0};
	int g,h,j,flage;
	long int min;
	int i;
	for(i=1;i<=16;i++)
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	while(3==scanf("%d%d%d",&g,&h,&j))
	{
		flage=0;
		if(g==-1&&h==-1&&j==-1)
			break;
		min=(abs(g-a[1])*abs(g-a[1])+abs(h-b[1])*abs(h-b[1])+abs(j-c[1])*abs(j-c[1]));
		for(i=1;i<=16;i++)
		{
			if(min>=(abs(g-a[i])*abs(g-a[i])+abs(h-b[i])*abs(h-b[i])+abs(j-c[i])*abs(j-c[i])))
			{
				min=(abs(g-a[i])*abs(g-a[i])+abs(h-b[i])*abs(h-b[i])+abs(j-c[i])*abs(j-c[i]));
				flage=i;
			}
		
		}
		printf("(%d,%d,%d) maps to (%d,%d,%d)\n",g,h,j,a[flage],b[flage],c[flage]);
	}
	return 0;
}

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