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

try it

Posted by scandrive at 2004-12-01 10:31:56 on Problem 1046
In 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:
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