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 |
测试数据全部正确~老是WA,快疯了……有极端情况么?#include<stdio.h> #include<math.h> int main() { int r[16],g[16],b[16],R,G,B,i=1,j=0,k; double d,p; do { scanf("%d%d%d",&R,&G,&B); if(j>15) { d=sqrt((r[0]-R)*(r[0]-R)+(g[0]-G)*(g[0]-G)+(b[0]-B)*(b[0]-B)); k=0; for(i=1;i<16;i++) { p=sqrt((r[i]-R)*(r[i]-R)+(g[i]-G)*(g[i]-G)+(b[i]-B)*(b[i]-B)); if(d>p) { d=p; k=i; } } printf("(%d,%d,%d) maps to (%d,%d,%d)\n",R,G,B,r[k],g[k],b[k]); } else { r[j]=R; g[j]=G; b[j]=B; j++; } }while(R!=-1||G!=-1||B!=-1); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator