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

请大家帮忙改一下

Posted by piaofushi919 at 2004-12-01 08:58:41 on Problem 1046
#include "stdio.h"
#include "math.h"
double distance(int x,int y,int z){
	return sqrt(x*x+y*y+z*z);
}         
void main(){
	int color[80][3],i=0,closest; 
	double temp,min;
	scanf("%d%d%d",&color[0][0],&color[0][1],&color[0][2]);
	while(color[i][0]>=0){
		i++;
		scanf("%d%d%d",&color[i][0],&color[i][1],&color[i][2]);
	}   
	for(int j=16;j<i;j++){
		min=700000; 
		for(int k=0;k<16;k++){
            int x=color[k][0]-color[k][0];
        	int y=color[k][1]-color[k][1];
        	int z=color[k][2]-color[k][2];
			temp=distance(x,y,z); 
			if(min>temp){    
				closest=k;                      
				min=temp;
			}
		}
		printf("(%d,%d,%d) maps to (%d,%d,%d)\n",color[j][0],color[j][1],color[j][2],color[closest][0],color[closest][1],color[closest][2]); 
	}
}

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