Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

额。。总是WA。我都郁闷了。。求高手指点下

Posted by Wangjie_Anne at 2008-11-30 09:13:53 on Problem 1046
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator