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 IC0590503101 at 2005-11-30 23:41:09 on Problem 1046
这是我辛苦做的

#include <stdio.h>
#include <math.h>
void main(){
        int R[16],G[16],B[16],D[16];
        int i=0,r,g,b,n=0;
		for(i=0;i<16;i++)
        scanf("%d %d %d",&R[i],&G[i],&B[i]);
a:  scanf("%d %d %d",&r,&g,&b);
	while(r!=-1&&g!=-1&&b!=-1){
	for(i=0;i<16;i++)
        D[i]=(R[i]-r)*(R[i]-r)+(G[i]-g)*(G[i]-g)+(B[i]-b)*(B[i]-b);
    for(i=1;i<16;i++)    
		if(D[i]<D[0]){
                D[0]=D[i];
				n=i;}
	       
        printf("(%d %d %d) maps to (%d %d %d)\n",r,g,b,R[n],G[n],B[n]);

goto a;}}




提交下面这个就可以,是同学的
#include<stdio.h>
void main(){
	int x[100],y[100],z[100],t[100];
	int i,j,a,b,c;
	for(i=1;i<17;i++)
		scanf("%d %d %d",&x[i],&y[i],&z[i]);
	scanf("%d %d %d",&a,&b,&c);
	while(a!=-1&&b!=-1&&c!=-1){
		int n=1;//这地方要先负值,不然的话就有可能
	    for(i=1;i<=16;i++)
	    	t[i]=(a-x[i])*(a-x[i])+(b-y[i])*(b-y[i])+(c-z[i])*(c-z[i]);
        for(i=2;i<=16;i++)
		    if(t[1]>t[i]){
			    j=t[1];
			    t[1]=t[i];
			    t[i]=j;
				n=i;
			}
	    printf("(%d,%d,%d) maps to (%d,%d,%d)\n",a,b,c,x[n],y[n],z[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