| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
错哪里啊????yunsile#include<iostream>
using namespace std;
typedef struct cell
{
int _R;
int _G;
int _B;
}Cell;
int main()
{
int r,g,b,j = 0,i,k;
long D[1024]={0};
Cell Rgb[16];
for(i = 0;i<16;i++)
cin>>Rgb[i]._R>>Rgb[i]._G>>Rgb[i]._B;
cin>>r>>g>>b;
while(r!=-1&&b!=-1&&g!=-1){
for(j = 0; j<16;j++)
D[j] = (Rgb[j]._R - r)*(Rgb[j]._R - r) + (Rgb[j]._G - g)*(Rgb[j]._G - g) + (Rgb[j]._B-b)*(Rgb[j]._B - b);
for(j=0,k=0;j<16;j++)
{
if(D[j]<=D[k])
k=j;
}
cout<<"("<<r<<","<<g<<","<<b<<") maps to ("<<Rgb[k]._R<<","<<Rgb[k]._G<<","<<Rgb[k]._B<<")"<<endl;
cin>>r>>g>>b;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator