| ||||||||||
| 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 | |||||||||
麻烦大家帮忙看看,在下实在无能为力了......怪的是在VC下可以运行出结果。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator