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

那位大侠帮忙改一下!

Posted by gxiverson at 2004-12-05 14:29:19 on Problem 1046
#include<iostream.h>
#include<math.h>
void main() {
	long a[16][3],i,min=255*255*255,b[100][3],k,p,t;
		for(i=0;i<=15;i++)
		{
			cin>>a[i][0];
			cin>>a[i][1];
			cin>>a[i][2];
		}
		do{
		for(k=0;k<=99;k++)
		{
			cin>>b[k][0];
			cin>>b[k][1];
			cin>>b[k][2];
		}
		}
		while((b[k][0]!=-1)&&(b[k][1]!=-1)&&(b[k][2]!=-1));
		for(k=0;k<=99;k++)
			for(i=0;i<=15;i++)
			{
				p=(b[k][0]-a[i][0])*(b[k][0]-a[i][0])+(b[k][1]-a[i][1])*(b[k][1]-a[i][1])+(b[k][2]-a[i][2])*(b[k][2]-a[i][2]);
				if(p<min)
				{
					min=p;
                    t=k;
				}
				cout<<"("<<b[k][0]<<","<<b[k][1]<<","<<b[k][2]<<")"<<"maps to"<<"("<<a[t][0]<<","<<a[t][1]<<","<<a[t][2]<<")"<<endl;
			}
}

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