zzulioj 1013: Find the distance between two points

Title description
Given the coordinates of two points A(x1, y1), B(x2, y2), calculate the distance between them.

Input The
input contains four real numbers x1, y1, x2, y2, separated by spaces, with the meaning as described. Where 0≤x1,x2,y1,y2≤100.

Output The
output occupies one line and contains a real number d, which represents the distance between A and B. The result is rounded to two decimal places.

Sample input Copy
1 1 2 2
Sample output Copy
1.41

#include<stdio.h>
#include<math.h>
int main()
{
    
    
	double x1, y1, x2, y2, d; 
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	d=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
	printf("%.2f\n",d);
	return 0;
}

Guess you like

Origin blog.csdn.net/m0_53024529/article/details/112698996