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 |
提交上去说答案错误。帮我看一下那里错了,谢谢,提交上去说Wrong Answer. #include<stdio.h> #include<math.h> float distance_fun(int x0,int y0,int z0,int x1,int y1,int z1);//求两点之间的距离 int main() { int i,j;//循环用变量 int n;//Number Of Provences int m;//Number Of Cities float a,b,c,d,x[4],y[4],z[4]; float sum_x=0,sum_y=0,sum_z=0;//坐标和 float ave_x=0,ave_y=0,ave_z=0;//重心 float distance=0; scanf("%f %f %f %f",&a,&b,&c,&d); scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&m); for(j=0;j<m;j++) { scanf("%f %f %f",&x[j],&y[j],&z[j]); } for(j=0;j<m;j++) { sum_x += x[j]; sum_y += y[j]; sum_z += z[j]; } ave_x = sum_x/3; ave_y = sum_y/3; ave_z = sum_z/3; for(j=0;j<m;j++) { distance += distance_fun(ave_x,ave_y,ave_z,x[j],y[j],z[j]); } printf("Province # %d : %.2f\n",i+1,distance); } return 0; } float distance_fun(int x0,int y0,int z0,int x1,int y1,int z1) //求两点之间的距离 { float dis; dis=sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)+(z0-z1)*(z0-z1)); return dis; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator