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 "stdio.h" #include "math.h" double distance(int x,int y,int z){ return sqrt(x*x+y*y+z*z); } void main(){ int color[80][3],i=0,closest; double temp,min; scanf("%d%d%d",&color[0][0],&color[0][1],&color[0][2]); while(color[i][0]>=0){ i++; scanf("%d%d%d",&color[i][0],&color[i][1],&color[i][2]); } for(int j=16;j<i;j++){ min=700000; for(int k=0;k<16;k++){ int x=color[k][0]-color[k][0]; int y=color[k][1]-color[k][1]; int z=color[k][2]-color[k][2]; temp=distance(x,y,z); if(min>temp){ closest=k; min=temp; } } printf("(%d,%d,%d) maps to (%d,%d,%d)\n",color[j][0],color[j][1],color[j][2],color[closest][0],color[closest][1],color[closest][2]); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator