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 xianghailian at 2003-12-16 17:35:51 on Problem 1046
#include <stdio.h>
#include <math.h>
void main(){
	int i=0,j=0,o,p,q;
	float d,D;
	struct colour{
		int x,y,z;
	}colour[16];
	struct score{
		int x,y,z;
	}score[6];
	for(i=0;i<16;i++)
		scanf("%d%d%d",&colour[i].x,&colour[i].y,&colour[i].z);
	for(j=0;j<6;j++)
		scanf("%d%d%d",&score[j].x,&score[j].y,&score[j].z);
	for(j=0;j<=5;j++){
              if((score[j].x!=-1)&&(score[j].y!=-1)&&(score[j].z!=-1)){
		   d=(float)sqrt((score[j].x-colour[0].x)*(score[j].x-colour[0].x)+(score[j].y-colour[0].y)*(score[j].y-colour[0].y)+(score[j].z-colour[0].z)*(score[j].z-colour[0].z));
                     for(i=0;i<16;i++){
			   D=(float)sqrt((score[j].x-colour[i].x)*(score[j].x-colour[i].x)+(score[j].y-colour[i].y)*(score[j].y-colour[i].y)+(score[j].z-colour[i].z)*(score[j].z-colour[i].z));
                              if(D<=d){
				   o=colour[i].x;
				   p=colour[i].y;
				   q=colour[i].z;
				   d=D;
			   }
		   }
		   printf("(%d,%d,%d) maps to(%d,%d,%d)",score[j].x,score[j].y,score[j].z,o,p,q);
		}
	}
}


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