现在的位置: 首页 > 综合 > 正文

POJ1046

2012年12月10日 ⁄ 综合 ⁄ 共 661字 ⁄ 字号 评论关闭
//POJ1046
//water 数学题
#include<iostream>
#include
<cstdio>
#include
<string>
#include
<cstdlib>
using namespace std;
struct node{
int x,y,z;
};
struct node RGB[20];
int main(){
for(int i=0;i<16;i++)
scanf(
"%d %d %d", &RGB[i].x,&RGB[i].y,&RGB[i].z);
int a,b,c;
while(1){
scanf(
"%d %d %d",&a,&b,&c);
if(a==-1)
break;
int t = (a-RGB[0].x)*(a-RGB[0].x) + (b-RGB[0].y)*(b-RGB[0].y) +(c-RGB[0].z)*(c-RGB[0].z);
int p = 0;
for(int i=1;i<16;i++)
if( t > (a-RGB[i].x)*(a-RGB[i].x) + (b-RGB[i].y)*(b-RGB[i].y) +(c-RGB[i].z)*(c-RGB[i].z) ){
t
= (a-RGB[i].x)*(a-RGB[i].x) + (b-RGB[i].y)*(b-RGB[i].y) +(c-RGB[i].z)*(c-RGB[i].z);
p
= i;
}
//(0,0,0) maps to (0,0,0)
printf("(%d,%d,%d) maps to (%d,%d,%d)\n",a,b,c,RGB[p].x,RGB[p].y,RGB[p].z);
}
return 0;
}

抱歉!评论已关闭.