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

把dmin的初始化放到while循环里面,每次都要置为最大

Posted by hawk at 2004-12-01 20:17:49 on Problem 1046
In Reply To:帮忙看看吧!谢谢!我真的不知道错哪了,我的意思是,这个程序在下面就通不过哦,但,呜呜,偶不知道错哪了! Posted by:90401307 at 2004-12-01 19:11:58
> 
> #include<stdio.h>
> int main(){
> 	int a[17],b[17],c[17];
> 	int p,q,r,i,d=0,dmin=255*255*255,index;
> 	for(i=1;i<=16;i++){
> 		scanf("%d %d %d",&a[i],&b[i],&c[i]);
> 	}
> 	scanf("%d %d %d",&p,&q,&r);
> 	while(p!=-1&&q!=-1&&r!=-1){
> 		for(i=1;i<=16;i++){
> 		    d=(a[i]-p)*(a[i]-p)+(b[i]-q)*(b[i]-q)+(c[i]-r)*(c[i]-r);
> 			if(d<dmin){
> 				dmin= d; 
> 				index=i;
> 			}
> 		}
> 		printf("(%d,%d,%d) maps to (%d,%d,%d)\n",p,q,r,a[index],b[index],c[index]);
> 		scanf("%d %d %d",&p,&q,&r);
> 	}
> 	return 0;
> }
> 
> 
> 

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