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 "math.h" #include "stdio.h" void main() { int a[16][3],i,x,y,z,t=0,min; for (i=0;i<16;i++) { scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]); } do { scanf("%d %d %d",&x,&y,&z); min=(x-a[0][0])*(x-a[0][0])+(y-a[0][1])*(y-a[0][1])+(z-a[0][2])*(z-a[0][2]); t=0; for (i=1;i<16;i++) { if ((x-a[i][0])*(x-a[i][0])+(y-a[i][1])*(y-a[i][1])+(z-a[i][2])*(z-a[i][2])<=min) { min=(x-a[i][0])*(x-a[i][0])+(y-a[i][1])*(y-a[i][1])+(z-a[i][2])*(z-a[i][2]); t=i; } } if (x!=-1&&y!=-1&&z!=-1) printf("(%d,%d,%d) maps to (%d,%d,%d)\n",x,y,z,a[t][0],a[t][1],a[t][2]); } while (x!=-1&&y!=-1&&z!=-1); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator