SDUT1047Color Me Less

来源:互联网 发布:淘宝手游充值 编辑:程序博客网 时间:2024/05/16 11:40
#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<iostream>#define MAX 0x3f3f3fusing namespace std;struct node{    double r,g,b;} a[20];double fd(struct node t,double x,double y,double z){    return sqrt((t.r-x)*(t.r-x)+(t.g-y)*(t.g-y)+(t.b-z)*(t.b-z));}int main(){    int k;    for(int i=0; i<16; i++)        scanf("%lf%lf%lf",&a[i].r,&a[i].g,&a[i].b);    double x,y,z;    while(scanf("%lf%lf%lf",&x,&y,&z)&&x!=-1&&y!=-1&&z!=-1)    {        double d=MAX;        for(int i=0; i<16; i++)            if(fd(a[i],x,y,z)<d)            {                d=fd(a[i],x,y,z);                k=i;            }        printf("(%.0lf,%.0lf,%.0lf) maps to (%.0lf,%.0lf,%.0lf)\n",x,y,z,a[k].r,a[k].g,a[k].b);    }}

0 0