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

麻烦大家帮忙看看,在下实在无能为力了......怪的是在VC下可以运行出结果。

Posted by qichao at 2009-07-20 20:57:54 on Problem 1046
#include<stdio.h>
#include<math.h>
int main()
{
	int color[16][4],i,j,a,b,c,k;
	long int s1,s2,s3;
	double min,s;
	for(i=0;i<16;i++)
		for(j=0;j<3;j++)
			scanf("%d",&color[i][j]);
	scanf("%d%d%d",&a,&b,&c);
	while(a!=-1&&b!=-1&&c!=-1)
	{
		for(i=0,min=100;i<16;i++)
		{
			s1=(color[i][0]-a)*(color[i][0]-a);
			s2=(color[i][1]-b)*(color[i][1]-b);
			s3=(color[i][2]-c)*(color[i][2]-c);
			s=sqrt(s1+s2+s3);
			if(min>s)
			{
				min=s;
				k=i;
			}
		}
		printf("(%d,%d,%d) maps to (%d,%d,%d)\n",a,b,c,color[k][0],color[k][1],color[k][2]);
		scanf("%d%d%d",&a,&b,&c);
	}
}

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