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

Re:请指教

Posted by F117_A at 2006-04-13 18:32:03 on Problem 2560
In Reply To:请指教 Posted by:F117_A at 2006-04-13 18:31:33
> #include<stdio.h>
> #include<memory.h>
> #include<math.h>
> struct spot{
> 	double x,y;
> }s[105];
> int n,mark[100],nMark;
> double dis,tem,mindis=1000000;
> void main()
> {	
> 	scanf("%d",&n);
> 	for(int i=0;i<n;i++)
> 		scanf("%lf %lf",&s[i].x,&s[i].y);
> 	for(int head=0;head<n;head++){	
> 		i=head;
> 		memset(mark,0,sizeof(mark));
> 		dis=0;
> 		int k=1;
> 		mark[i] = 1;
> 		while(k<n){
> 			tem=1000000;
> 			for(int j=0;j<n;j++)
> 				if(mark[j])continue;
> 				else {
> 					double temp = (s[i].x-s[j].x)*(s[i].x-s[j].x) + (s[i].y-s[j].y)*(s[i].y-s[j].y);
> 					if(temp < tem){
> 					tem = temp;
> 					nMark = j;
> 					}
> 				}
>                 dis+=sqrt(tem);
> 				mark[nMark] = 1;
> 				i=nMark;
> 				k++;
> 		}
> 		if(dis < mindis)
> 			mindis=dis;
> 	}
> 	printf("%.2lf\n",mindis);
> }
> 

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