A comparison and a plurality of sets of a given point x-axis, each set of two points, the distance between the number and find a set of points of the point farthest.

Description Title:
input
a first row is the number of n (0 <n <10) points.
Each line represents two points followed by two floating point numbers x1, x2 composition.
Output
the output line length is set between the farthest point, accurate to four decimal places.
Input Sample
6
34.0 23.0
28.1 21.6
14.7 17.1
17.0 27.2
29.3 70.1
34.7 67.1
Sample Output
5 40.8000

# include<stdio.h>
# include<math.h>  
int main()
{
	int m,n,i,max1;
	double a[1000],b[1000],max2=0;
	scanf("%d",&n);
	for(m=0;m<n*2;m++)
	{
		scanf("%lf",&a[m]);
	}
	for(m=1,i=0;m<n*2;m+=2,i++)
	{
		b[i]=fabs(a[m]-a[m-1]);//运用绝对值函数
		if(b[i]>max2)
		{
			max1=i;
			max2=b[i];
		}
	}
	printf("%d %0.4lf",max1+1,max2);
	return 0;
	
 } 

Note: differences and the requirements of the subject FABS () and ABS () function.

Published 43 original articles · won praise 1 · views 759

Guess you like

Origin blog.csdn.net/Du798566/article/details/104258731