Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么总是wrong answer?救救大一新生吧!!!!!!

Posted by tears at 2005-11-24 14:33:32 on Problem 1046
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator