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

哪位高手麻烦帮忙看看,谢谢啦 1046 为什么一直WA啊……

Posted by acm_pku at 2007-10-20 21:40:55
#include "stdio.h"
int main()
{
	int i,j,r,g,b,y1,y2,y3,min,x,a[17][4];
	for(i=1;i<=16;i++)
	{
		for(j=1;j<=3;j++)
			scanf("%d",&a[i][j]);
	}
	scanf("%d%d%d",&r,&g,&b);
	while(r!=-1&&g!=-1&&b!=-1)
	{
		min=1000000;
		for(i=1;i<=16;i++)
		{
			x=(r-a[i][1])*(r-a[i][1])+(g-a[i][2])*(r-a[i][2])+(b-a[i][3])*(b-a[i][3]);
			if(x<min)
			{
				min=x;
				y1=a[i][1];
				y2=a[i][2];
				y3=a[i][3];
			}
		}
		printf("(%d,%d,%d) maps to (%d,%d,%d)\n",r,g,b,y1,y2,y3);
        scanf("%d%d%d",&r,&g,&b);
	}
	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