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 |
你的测试数据有点问题哦,最后一个数据不正确In Reply To:ac了 Posted by:sail6 at 2006-10-10 11:34:09 > #include<iostream.h> > #include<math.h> > int main() > { > double a[16][3]; > int i,j; > for(i=0;i<16;i++) > { > for(j=0;j<3;j++) > { > cin>>a[i][j]; > } > } > double b[3]; > while(cin>>b[0]) > { > cin>>b[1]>>b[2]; > if(b[0]==-1&&b[1]==-1&&b[2]==-1)break; > int rem; > double com=0,check=0; > rem=0; > for(j=0;j<3;j++) > com+=(a[0][j]-b[j])*(a[0][j]-b[j]); > com=sqrt(com); > //cout<<com<<endl; > for(i=1;i<16;i++) > { > check=0; > for(j=0;j<3;j++) > { > check+=(b[j]-a[i][j])*(b[j]-a[i][j]); > } > check=sqrt(check); > if(check<com) > { > rem=i; > com=check; > } > > } > /*//cout<<'('; > //for(j=0;j<3;j++) > cout<<b[j]<<','; > cout<<") maps to ("; > for(j=0;j<3;j++) > cout<<a[rem][j]<<','; > cout<<')'<<endl;;*/ > cout<<"("<<b[0]<<","<<b[1]<<","<<b[2]<<") maps to ("<<a[rem][0]<<","<<a[rem][1]<<","<<a[rem][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