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

贴C++代码!!!!!

Posted by 1006840633 at 2011-09-19 23:19:35 on Problem 1046
#include<iostream>
#define M 50
using namespace std;
int distance(int a1[],int a2[])
{
	return  ((a2[0]-a1[0])*(a2[0]-a1[0])+(a2[1]-a1[1])*(a2[1]-a1[1])+(a2[2]-a1[2])*(a2[2]-a1[2]));
}
int main()
{
	int a[M][3],index=0;
	for(int i=0;i<M;i++)
	{
		for(int j=0;j<3;j++)
			cin>>a[i][j];
		if(a[i][0]==-1&&a[i][1]==-1&&a[i][2]==-1)
			break;
	}
	for(int k=16;;k++)
	{
		for(int m=0;m<16;m++)
			for(int n=0;n<16-m;n++)
				if(distance(a[k],a[n])<distance(a[k],a[index]))
					index=n;
		if(a[k][0]==-1&&a[k][1]==-1&&a[k][2]==-1)
			break;
		cout<<"("<<a[k][0]<<","<<a[k][1]<<","<<a[k][2]<<") maps to ("<<a[index][0]<<","<<a[index][1]<<","<<a[index][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