| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
高手点一下。这个怎么wa?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator