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:道歉 道歉,我其实是没说好,自己也觉的不妥,不过也是想表扬一下大家了,请不吝赐教啦.

Posted by kicc at 2006-04-24 12:59:14 on Problem 1046
In Reply To:道歉 道歉,我其实是没说好,自己也觉的不妥,不过也是想表扬一下大家了,请不吝赐教啦. Posted by:winter_1 at 2006-04-24 12:46:51
#include<stdio.h>
void main()
{
	struct color{
		int a;
		int b;
		int c;
	};
	struct color vb[16];
	int i,k1,k2,k3,t1,t2,t3,min=0;
	for(i=0;i<16;i++){ 
		scanf("%d %d %d",&vb[i].a,&vb[i].b,&vb[i].c);
	}
	int x,y,z;
	while(1){
		scanf("%d %d %d",&x,&y,&z);
		if(x==-1&&y==-1&&z==-1){
			break;
		}	
	        min = 0; // <---------------------
		for(i=1;i<16;i++){
			k1=x-vb[min].a;
			k2=y-vb[min].b;
			k3=z-vb[min].c;
			t1=x-vb[i].a;
			t2=y-vb[i].b;
			t3=z-vb[i].c;
			if(k1*k1+k2*k2+k3*k3>t1*t1+t2*t2+t3*t3){
				min=i;
			}
		}
	
		printf("(%d,%d,%d) maps to (%d,%d,%d)\n",x,y,z,vb[min].a,vb[min].b,vb[min].c);
	
	}
}


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