求平面内两点之间的距离

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
#include <math.h>
int main()
{
    float a, b, c, d, e, f, g;
    printf("Please enter the coordinates of two point, A(a,b) B(c,d), input like a= ,b=,c= ,d= \n");
    scanf("a=%f,b=%f,c=%f,d=%f", &a, &b, &c, &d);
    e = (a - c);
    f = (b - d);
    g = sqrt(e * e + f * f);
    printf("The distance of A and B is: %8.2f", g);
    return 0;
}