POJ 1046
#include<iostream> using namespace std; #define MAXN 16 #define inf 100000000 struct node { int x; int y; int z; }; node _m[MAXN]; int main() { //freopen("acm.acm","r",stdin); int i; int x; int y; int z; int min; int tem; int ans; for(i = 0; i < 16; ++ i) { cin>>_m[i].x>>_m[i].y>>_m[i].z; } while(cin>>x>>y>>z) { min = inf; if(x == -1 && y == -1 && z == -1) { break; } for(i = 0; i < 16; ++ i) { tem = (x - _m[i].x)*(x - _m[i].x) + (y - _m[i].y)*(y - _m[i].y) + (z - _m[i].z)*(z - _m[i].z); if(tem < min) { ans = i; min = tem; } } cout<<"("<<x<<","<<y<<","<<z<<") maps to ("<<_m[ans].x<<","<<_m[ans].y<<","<<_m[ans].z<<")"<<endl; } }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com