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 |
why?c只存了16个值In Reply To:wa可能就是你的数组设小了 Posted by:zpdlut at 2010-09-08 19:54:23 > 我一开始设成50就wa,设成200就ac了 > #include<iostream> > #include<math.h> > #define MAX 200 > using namespace std; > struct color > { > int red; > int blue; > int green; > }; > int main() > { > int r,b,g; > color c[MAX]; > for(int i=0;i<16;i++) > { > cin>>c[i].red>>c[i].blue>>c[i].green; > } > while(cin>>r>>b>>g) > { > if(r==-1&&b==-1&&g==-1) > break; > int min=1<<20; > int flag=0; > for(int i=0;i<20;i++) > { > int length = sqrt(pow((r-c[i].red)*1.0,2)+pow((b-c[i].blue)*1.0,2)+pow((g-c[i].green)*1.0,2)); > if(length<min) > { > min = length; > flag = i; > } > } > cout<<"("<<r<<","<<b<<","<<g<<") maps to ("<<c[flag].red<<","<<c[flag].blue<<","<<c[flag].green<<")"<<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