POJ 1046 Color Me Less

先输入16个像素点,然后每输入一个像素点,输出与其最相近的像素点。

 

/* Accepted 176K 0MS C++ 664B 2012-05-04 22:34:22 */



#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#define MAXN 20

int A[MAXN], B[MAXN], C[MAXN];

int a, b, c;

int k;



int main()

{

    for( int i = 0; i < 16; i ++)

        scanf( "%d%d%d", &A[i], &B[i], &C[i]);

    while( scanf( "%d%d%d", &a, &b, &c) == 3)

    {

        if( a == -1 || b == -1 || c == - 1) break;

        double min = 0x3f3f3f3f;

        for( int i = 0; i < 16; i ++)

        {

            double ans = sqrt( (double)((a - A[i]) * ( a - A[i]) + ( b - B[i]) * ( b - B[i]) + (c - C[i]) * ( c - C[i]) ));

            if( min > ans) {

                min = ans;

                k = i;

            }

        }

        printf( "(%d,%d,%d) maps to (%d,%d,%d)\n", a, b, c, A[k], B[k], C[k]);

    }

    return 0;

}

 

 

 

你可能感兴趣的:(color)