#include <stdio.h> #include <math.h>

struct Point2D { double x; double y; };

int main() { struct Point2D p1, p2; double distance;

printf('Enter the coordinates of point 1:\n');
scanf('%lf %lf', &p1.x, &p1.y);

printf('Enter the coordinates of point 2:\n');
scanf('%lf %lf', &p2.x, &p2.y);

distance = sqrt(pow(p2.x - p1.x, 2) + pow(p2.y - p1.y, 2));

printf('The distance between the two points is: %.2f', distance);

return 0;

}

C语言计算两点间距离 - 结构体和数学函数

原文地址: https://www.cveoy.top/t/topic/os7d 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录