//简单题,由于数组开小了,WA了一次,水啊!
#include "iostream"
#include "climits"
#include "cstdio"
using namespace std;
struct Info
{
int r;
int g;
int b;
};
int main()
{
Info info[20], temp, ans;
int i, max;
for (i = 0; i <= 15; i++)
cin >> info[i].r >> info[i].g >> info[i].b;
while (1)
{
cin >> temp.r >> temp.g >> temp.b;
if (temp.r == -1 && temp.g == -1 && temp.b == -1) break;
max = INT_MAX;
for (i = 0; i <= 15; i++)
{
int dis = (temp.r - info[i].r)*(temp.r - info[i].r) + (temp.g - info[i].g)*(temp.g - info[i].g) + (temp.b - info[i].b)*(temp.b - info[i].b);
if (max > dis)
{
ans.r = info[i].r;
ans.g = info[i].g;
ans.b = info[i].b;
max = dis;
}
}
printf("(%d,%d,%d) maps to (%d,%d,%d)\n", temp.r, temp.g, temp.b, ans.r, ans.g, ans.b);
}
system("pause");
}
poj 1046 Color Me Less
最新推荐文章于 2024-11-11 13:11:08 发布