zoj 1067 Color Me Less

来源:互联网 发布:linux vi使用 编辑:程序博客网 时间:2024/04/28 10:53

#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <string>#include <cmath>#include <vector>#include <queue>#include <climits>#include <stack>#include <algorithm>using namespace std;struct color{       int r, p, g;}map[20];int i;int main(){    for(i = 1; i <= 16; i++)    {          scanf("%d%d%d", &map[i].r, &map[i].p, &map[i].g);    }    color c;    while(scanf("%d%d%d", &c.r, &c.p, &c.g) && c.r >= 0)    {        float MIN = 195076;        int index = 0;        for(i = 1; i <= 16; i++)        {              float tmp = (map[i].r - c.r)*(map[i].r - c.r)+                          (map[i].p - c.p)*(map[i].p - c.p)+                          (map[i].g - c.g)*(map[i].g - c.g);              if(tmp < MIN)               {                     MIN = tmp;                     index = i;              }        }        printf("(%d,%d,%d) maps to ", c.r, c.p, c.g);        printf("(%d,%d,%d)\n", map[index].r, map[index].p, map[index].g);    }    return 0;}

注意输出格式,网站上的显示不清楚,复制到记事本上就清楚了,输出格式错误的话,给的结果是wa


原创粉丝点击