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> using namespace std; int main() { int a,b,c,d,e,f,m1,m2=0; int i=0; int s[48]={0}; do { cin>>a>>b>>c; if(a<0||a>255||b<0||b>255||c<0||c>255) return 0; s[3*i]=a; s[3*i+1]=b; s[3*i+2]=c; i++; }while(i<16); cin>>d>>e>>f; while(d>=0&&d<=255&&e>=0&&e<=255&&f>=0&&f<=255&&d!=-1&&e!=-1&&f!=-1) { m1=(d-s[0])*(d-s[0])+(e-s[1])*(e-s[1])+(f-s[2])*(f-s[2]); for(int j=3;j<48;j+=3) { if(m1>(d-s[j])*(d-s[j])+(e-s[j+1])*(e-s[j+1])+(f-s[j+2])*(f-s[j+2])) { m2=j; m1=(d-s[j])*(d-s[j])+(e-s[j+1])*(e-s[j+1])+(f-s[j+2])*(f-s[j+2]); } } cout<<"("<<d<<","<<e<<","<<f<<") maps to ("<<s[m2]<<","<<s[m2+1]<<","<<s[m2+2]<<")"<<endl; cin>>d>>e>>f; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator