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<iostream> #include<cmath> using namespace std; int main() { int a[16][3]; int x,y,z; double min = 600.0,t; int k; for(int i = 0 ;i<16; i++) cin>>a[i][0]>>a[i][1]>>a[i][2]; while(cin>>x>>y>>z) { if(x==-1&&y==-1&&z==-1) break; min = 600.0; for(int j =0; j<16; j++) { t =sqrt((a[j][0]-x)*(a[j][0]-x)+(a[j][1]-y)*(a[j][1]-y)+(a[j][2]-z)*(a[j][2]-z)); if(t<min) { min = t; k =j; } } cout<<"("<<x<<","<<y<<","<<z<<") "<<"maps to ("<<a[k][0]<<","<<a[k][1]<<","<<a[k][2]<<")"<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator