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

Posted by colinzhong at 2009-07-06 21:21:10 on Problem 1046
#include<iostream>
#include<math.h>
using namespace std;

struct RGB1
{
int x, y, z;
};

double distance(RGB1 a, RGB1 b)
{
return sqrt(double((a.x - b.x)*(a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z)));
}
int main()
{
	RGB1 gg[16];
	 int i;
	 for(i = 0; i <= 15; i++)
	{
	 cin >> gg[i].x >> gg[i].y >> gg[i].z;
	}
	RGB1 mm;
	RGB1 temp;
	while(cin >> mm.x >> mm.y >> mm.z, mm.x != -1 && mm.y != -1&& mm.z!=-1)
	{
		double min = 65535;
		for(i = 0; i <= 15; i++)
		{
			if(distance(mm, gg[i])< min)
			{
				min = distance(mm, gg[i]);
				temp.x = gg[i].x;
				temp.y = gg[i].y;
				temp.z = gg[i].z;
			}
		}
		cout <<'('<<mm.x<<','<<mm.y<<','<<mm.z<<')'<<" maps to ("<<temp.x<<','<<temp.y<<','<<temp.z<<')'<<endl;
	}
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