| ||||||||||
| 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 | |||||||||
额。。总是WA。我都郁闷了。。求高手指点下#include <stdio.h>
#include <math.h>
int main()
{int i,j,t;
int a[16][3],r,g,b;
for(i=0;i<16;i++)
{scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);}
while((scanf("%d%d%d",&r,&g,&b))&&(r!=-1&&g!=-1&&b!=-1))
{
int hold=(r-a[0][0])*(r-a[0][0])+(g-a[0][1])*(g-a[0][1])+(b-a[0][2])*(b-a[0][2]);
for(j=0;j<16;j++)
{int D=(r-a[j][0])*(r-a[j][0])+(g-a[j][1])*(g-a[j][1])+(b-a[j][2])*(b-a[j][2]);
t=0;
if(D<hold)
{
hold=D;
t=j;
}
}
printf("(%d,%d,%d) maps to (%d,%d,%d)\n",r,g,b,a[t][0],a[t][1],a[t][2]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator