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 zhangkeabcd123321 at 2010-05-09 16:34:08 on Problem 1046
#include <iostream>
#include <math.h>
using namespace std;
int r[10000],g[10000],b[10000],th[10000];
float d[10000][10000];
int main()
{
	int i,j,k, x,y,z;
	float q;
	i=1;
	k=0;
	x=1;
	y=1;
	z=1;
	while(x!=-1&&y!=-1&&z!=-1)
	{
		scanf("%d%d%d",&x,&y,&z);
		r[i]=x;
		g[i]=y;
		b[i]=z;
		i++;
		k++;
	}
	for(i=17;i<k;i++)
	{
		for(j=1;j<=16;j++)
		{
			d[i][j]=(double)sqrt((double)((r[i]-r[j])*(r[i]-r[j])+(g[i]-g[j])*(g[i]-g[j])+(b[i]-b[j])*(b[i]-b[j])));
		}
		q=d[i][1];
		for(j=2;j<=16;j++)
		{
			if(q>=d[i][j])
				q=d[i][j];
		}
		for(j=1;j<=16;j++)
		{
			if(d[i][j]==q)
			{
				th[i]=j;
			}
		}
	}
	for(i=17;i<k;i++)
	{
		cout<<"("<<r[i]<<","<<g[i]<<","<<b[i]<<")"<<" maps to "<<"("<<r[th[i]]<<","<<g[th[i]]<<","<<b[th[i]]<<")"<<endl;
	}
	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