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

Re:第25题了,路过,贴下代码。

Posted by huangiris at 2012-07-09 16:45:25 on Problem 1046
In Reply To:第25题了,路过,贴下代码。 Posted by:qifeifei at 2010-06-01 22:59:31
> #include "iostream"
> #define MAX 10000
> using namespace std;
> 
> struct node  
> {
> 	int a;
> 	int b;
> 	int c;
> }s[MAX];
> int main(int argc, char* argv[])
> {
> 	node Q;
> 	int top=-1,m,i,p,n;
> 	long r,t;
> 	while(1)
> 	{
> 		cin>>Q.a>>Q.b>>Q.c;
> 		if(Q.a==-1&&Q.b==-1&&Q.c==-1) break;
> 		top++;
> 		s[top]=Q;
> 	}
> 	i=16;
> 	for(m=i;m<=top;m++)
> 	{
> 		r=32767;p=0;
> 		for(n=0;n<16;n++)
> 		{
> 			t=(s[m].a-s[n].a)*(s[m].a-s[n].a)+(s[m].b-s[n].b)*(s[m].b-s[n].b)+(s[m].c-s[n].c)*(s[m].c-s[n].c);
> 			if(t<r)
> 			{
> 				r=t;
> 				p=n;
> 			}
> 		}
> 		cout<<'('<<s[m].a<<','<<s[m].b<<','<<s[m].c<<')'<<' '<<"maps"<<' '<<"to"<<' ';
> 		cout<<'('<<s[p].a<<','<<s[p].b<<','<<s[p].c<<')'<<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