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 |
为什么我的总是错误?帮忙看一下。,谢谢了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator