| ||||||||||
| 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 | |||||||||
为什么总是wrong answer?救救大一新生吧!!!!!!#include <stdio.h>
#include <math.h>
void main(){
int R[16],G[16],B[16],D[16];
int i,j,a,b,c;
for(i=0;i<=15;i++){
scanf("%d %d %d",&R[i],&G[i],&B[i]);
}
scanf("%d %d %d",&a,&b,&c);
while(a!=-1&&b!=-1&&c!=-1){
int n=1;
for(i=0;i<=15;i++){
D[i]=(a-R[i])*(a-R[i])+(b-G[i])*(b-G[i])+(c-B[i])*(c-B[i]);
}
for(i=1;i<=15;i++){
if(D[i]<D[0]){
j=D[0];
D[0]=D[i];
D[i]=j;
n=i;
}
}
printf("(%d,%d,%d) maps to (%d,%d,%d)\n",a,b,c,R[n],G[n],B[n]);
scanf("%d %d %d",&a,&b,&c);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator