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

为什么会CE 说sqrt错了

Posted by Cabinfever at 2013-11-15 21:11:41 on Problem 1046
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
int main()
{
	#define maxn 16
	int a[20],b[20],c[20],x,y,z,minsign;
	double ans,minpoint;
	for(int i=1;i<=maxn;i++)
	{
		scanf("%d%d%d\n",&a[i],&b[i],&c[i]);
	}
	while(scanf("%d%d%d\n",&x,&y,&z),x!=-1)
	{
		minpoint=9999999;
		for(int i=1;i<=maxn;i++)
		{
			ans=sqrt((a[i]-x)*(a[i]-x)+(b[i]-y)*(b[i]-y)+(c[i]-z)*(c[i]-z));
			if(ans<minpoint)
			{
				minpoint=ans;
				minsign=i;
			}
		}
		printf("(%d,%d,%d) maps to (%d,%d,%d)\n",x,y,z,a[minsign],b[minsign],c[minsign]);
	}
	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