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 90405127 at 2004-12-04 14:45:19 on Problem 1046
#include<stdio.h>
#include<math.h>
void main(){
	int min,l,i,j,d,a,b,c,x[16],y[16],z[16];
	for(i=0;i<16;i++)
	{
	    scanf("%d %d %d",&x[i],&y[i],&z[i]);
	}
	scanf("%d %d %d",&a,&b,&c);
	if(!(a==-1&&b==-1&&c==-1)){
	min=(x[0]-a)^2+(y[0]-b)^2+(z[0]-c)^2;
	for(j=1;j<16;j++)
	{
		d=(x[j]-a)^2+(y[j]-b)^2+(z[j]-c)^2;
		if(d<=min)
		{
			min=d;
		    l=j;
		}
	    
	}
	printf("(%d,%d,%d) maps to (%d,%d,%d)\n",a,b,c,x[l],y[l],z[l]);
}}

是不是l的赋值不对啊?
		





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