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 |
这个有什么问题吗?怎么老是CE#include<iostream> #include<math.h> using namespace std; struct RGB1 { int x, y, z; }; double distance(RGB1 a, RGB1 b) { return sqrt(double((a.x - b.x)*(a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z))); } int main() { RGB1 gg[16]; int i; for(i = 0; i <= 15; i++) { cin >> gg[i].x >> gg[i].y >> gg[i].z; } RGB1 mm; RGB1 temp; while(cin >> mm.x >> mm.y >> mm.z, mm.x != -1 && mm.y != -1&& mm.z!=-1) { double min = 65535; for(i = 0; i <= 15; i++) { if(distance(mm, gg[i])< min) { min = distance(mm, gg[i]); temp.x = gg[i].x; temp.y = gg[i].y; temp.z = gg[i].z; } } cout <<'('<<mm.x<<','<<mm.y<<','<<mm.z<<')'<<" maps to ("<<temp.x<<','<<temp.y<<','<<temp.z<<')'<<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