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

帮忙看一下,谢

Posted by 90305116 at 2003-12-12 19:15:33 on Problem 1046
这个本机测试一点问题都没有啊~~~
#include <math.h>
#include <stdio.h>

void main()
{
	int j,k,m,n;
	float min;
	float d[100][16];
	float a[16];
	struct colour
	{
		int r;
		int g;
		int b;
	}colour_t[16],colour[6];



	for(j=0;j<16;j++)
	{
	scanf("%d%d%d",&colour_t[j].r,&colour_t[j].g,&colour_t[j].b);
	}

	for(k=0;;k++)
	{
		scanf("%d%d%d",&colour[k].r,&colour[k].g,&colour[k].b);
		if(colour[k].r==-1||colour[k].g==-1||colour[k].b==-1)
			break;
		else
		{
			for(m=0;m<16;m++) 
			{

				d[k][m]=sqrt((colour[k].r-colour_t[m].r)*(colour[k].r-colour_t[m].r)+(colour[k].g-colour_t[m].g)*(colour[k].g-colour_t[m].g)+(colour[k].b-colour_t[m].b)*(colour[k].b-colour_t[m].b));
				
			a[m]=d[k][m];
			
		
			}
				
			for(m=0,min=a[0];m<15;m++)
			{
				if(min>=a[m+1])
					min=a[m+1];

			}
			for(m=0;m<16;m++)
			{
				if(d[k][m]==min)
					printf("(%d,%d,%d) maps to (%d,%d,%d)\n", colour[k].r,colour[k].g,colour[k].b, colour_t[m].r,colour_t[m].g,colour_t[m].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