| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
pass#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator