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 gongbanban at 2009-12-07 18:24:23 on Problem 1046
#include<stdio.h>
#include<math.h>
struct pp
{
 double x;
 double y;
 double z;
};
 struct pp a[17];
int f(double x,double y,double z)
{ 
 int mini=0,i;
 double min,x1,x2,x3;
 min=300000;
 for(i=0;i<16;i++)
  {
   x1=x-a[i].x;
   x2=y-a[i].y;
   x3=z-a[i].z;
   if(sqrt(x1*x1+x2*x2+x3*x3)<min) 
                                 {
                                min=sqrt(x1*x1+x2*x2+x3*x3);
                                mini=i;
                                   }
 }    
  return mini;
}
int main()
{
  int i,h;
  double x,y,z;
  FILE *fp;
  for(i=0;i<16;i++)
   scanf("%lf %lf %lf",&a[i].x,&a[i].y,&a[i].z);
  while(1)
   {
    scanf("%lf %lf %lf",&x,&y,&z);
    if((x==-1.0)&&(y==-1.0)&&(z==-1.0))break;
    h=f(x,y,z);
    printf("(%.0lf,%.0lf,%.0lf) maps to (%.0lf,%.0lf,%.0lf)\n",x,y,z,a[h].x,a[h].y,a[h].z);
   }
 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