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

pass

Posted by niuniu2006 at 2007-04-09 14:25:47 on Problem 1046
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	double arr[100][3];
	double d=0;
	double max=500;
	int i=0;
	int j=0;
	int re[100];
	while(arr[i-1][0]!=-1&&arr[i-1][1]!=-1&&arr[i-1][2]!=-1)
	{	
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
		++i;
	}
/*	for(int jj=0;jj<=i-2;++jj)
		cout<<arr[jj][0]<<' '<<arr[jj][1]<<' '<<arr[jj][2]<<endl;*/

	for(int b=16;b<=i-2;++b)
	{
		for(int f=0;f<=15;++f)
		{
			d=sqrt((arr[b][0]-arr[f][0])*(arr[b][0]-arr[f][0])+(arr[b][1]-arr[f][1])*(arr[b][1]-arr[f][1])+(arr[b][2]-arr[f][2])*(arr[b][2]-arr[f][2]));
			if(d<max)
			{
				j=f;
				max=d;
			}
			if(d==0)
			{
				j=f;
				break;
			}
		}
		re[b-16]=j;
		max=500;
	}
	for(int jjj=0;jjj<=i-18;++jjj)
		cout<<'('
		    <<arr[16+jjj][0]
			<<','
			<<arr[16+jjj][1]
			<<','
			<<arr[16+jjj][2]
			<<')'
			<<" "
			<<"maps to "
			<<'('
			<<arr[re[jjj]][0]
			<<','
			<<arr[re[jjj]][1]
			<<','
			<<arr[re[jjj]][2]
			<<')'
			<<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