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 |
while(cin>>c[0]>>c[1]>>c[2])改成while(cin>>c[0]>>c[1]>>c[2] && c[0]!=-1 && c[1]!=-1 && c[2]!=-1)In Reply To:为什么老是WA Posted by:NENU08022 at 2009-01-15 21:18:32 > #include<iostream> > #include<cmath> > using namespace std; > int main() > { > int a[16][3],b[16],c[3],i,j; > for( i=0;i<16;i++) > for( j=0;j<3;j++) > cin>>a[i][j]; > while(cin>>c[0]>>c[1]>>c[2]) > { > int m=500; > int num=0; > for(i=0;i<16;i++) > { > b[i]=sqrt(float((c[0]-a[i][0])*(c[0]-a[i][0])+(c[1]-a[i][1])*(c[1]-a[i][1])+(c[2]-a[i][2])*(c[2]-a[i][2]))); > if(b[i]<m) > { > m=b[i];num=i; > } > } > cout<<"("<<c[0]<<","<<c[1]<<","<<c[2]<<") maps to ("<<a[num][0]<<","<<a[num][1]<<","<<a[num][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