用C语言编写程序,要求使用结构体定义点,通过键盘输入2个点的坐标,计算这两点之间的距离。
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
struct POINT
{
double x,y;
};int main()
{
struct POINT a,b;
printf("输入a点的坐标:");
scanf("%lf%lf",&a.x,&a.y);
printf("输入b点的坐标:");
scanf("%lf%lf",&b.x,&b.y);
double len=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
printf("两点距离: %lf",len);
}