| ||||||||||
| 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 | |||||||||
try itIn Reply To:谁能帮我改改? Posted by:90401306 at 2004-11-27 17:18:01
#include<stdio.h>
void main()
{
int R,G,B,i,j,k,a[16][3],d[16];
for(i=0;i<16;i++)
scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
scanf("%d %d %d",&R,&G,&B);
while(R!=-1&&G!=-1&&B!=-1)
{
for(i=0;i<16;i++)
d[i]=(R-a[i][0])*(R-a[i][0])+(G-a[i][1])*(G-a[i][1])+(B-a[i][2])*(B-a[i][2]);
for(j=0,k=0;j<16;j++)
{
if(d[j]<=d[k])
k=j;
}
printf("(%d,%d,%d) maps to (%d,%d,%d)\n",R,G,B,a[k][0],a[k][1],a[k][2]);
scanf("%d %d %d",&R,&G,&B);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator