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<stdlib.h> struct position{ int R;int G;int B;int W;}point[1000]; int i,j,k,m,n,p,q; void main(){ for(i=0;i<1000;i++){ scanf("%d%d%d",&point[i].R,&point[i].G,&point[i].B);q=i; if(point[i].R==-1&&point[i].G==-1&&point[i].B==-1) break;} for(j=16;j<q;j++){ for(k=0;k<15;k++){ m=(point[j].R-point[k].R)*(point[j].R-point[k].R) +(point[j].G-point[k].G)*(point[j].G-point[k].G) +(point[j].B-point[k].B)*(point[j].B-point[k].B); n=(point[j].R-point[k+1].R)*(point[j].R-point[k+1].R) +(point[j].G-point[k+1].G)*(point[j].G-point[k+1].G) +(point[j].B-point[k+1].B)*(point[j].B-point[k+1].B); if(m>n) m=n;} for(k=0;k<16;k++){ p=(point[j].R-point[k].R)*(point[j].R-point[k].R) +(point[j].G-point[k].G)*(point[j].G-point[k].G) +(point[j].B-point[k].B)*(point[j].B-point[k].B); if(p==m) point[j].W=k;} } for(j=16;j<q;j++){ printf("\n(%d,%d,%d) maps to (%d,%d,%d)",point[j].R,point[j].G, point[j].B,point[point[j].W].R,point[point[j].W].G, point[point[j].W].B);} system("PAUSE"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator