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

牛人们帮帮忙啊,就是过不了,郁闷啊~~急救!!!wrong

Posted by 00448166 at 2005-04-28 16:15:45 on Problem 1046
#include <iostream>
using namespace std;
#include <math.h>
int a[16][3];
int b[3],c[3];
long double d[16];
int i,j;
double findD(int p[16][3],int q[3],int i1)
{
	long double t=(long double)((p[i1][0]-q[0])*(p[i1][0]-q[0])+(p[i1][1]-q[1])*(p[i1][1]-q[1])+(p[i1][2]-q[2])*(p[i1][2]-q[2]));
	long double D;
	D=(long double) sqrt(t);
	return D;
}

void main()
{
	long double min=0;
	for(i=0;i<16;i++)
		for(j=0;j<3;j++)
			cin>>a[i][j];
	while(1)
	{
		cin>>b[0]>>b[1]>>b[2];
		if(b[1]==-1&&b[0]==-1&&b[2]==-1)
			break;
		for(i=0;i<16;i++)
		{
			d[i]=findD(a,b,i);
		}
		min=d[0];
		for(i=1;i<16;i++)
		{
			if(min>d[i])
			{
				min=d[i];
				for(j=0;j<3;j++)
					c[j]=a[i][j];
			}
				
		}
		cout<<"("<<b[0]<<","<<b[1]<<","<<b[2]<<")"<<" maps to "<<"("<<c[0]<<","<<c[1]<<","<<c[2]<<")"<<endl;
	}
	return;
}

		
		

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