求两点间的距离,不知道为什么写了个程序算出来数字天差地别。

【问题描述】

提示用户输入两个点的坐标,然后计算并输出这两个点之间的距离。两点坐标为(x1,y1), (x2,y2),距离为对应坐标差的平方和,再开平方。输出的距离保留4位小数。

注意开平方调用的是库函数sqrt(), 函数原型为float sqrtf(float), 在头文件math.h中声明的。

【输入形式】
【输出形式】
【样例输入】

(2.3,4.5)

(10,8.7)
【样例输出】

Please input the coordinates of two points:
point 1(x,y):
point 2(x,y):
This distance is: 8.7710

有啥问题?

#include <stdio.h>
#include <math.h>
int main()
{
    double x1,y1,x2,y2;
    printf("Please input the coordinates of two points:\n");
    printf("point 1(x,y):");
    scanf("(%lf,%lf)",&x1,&y1);
    printf("point 2(x,y):");
    scanf("(%lf,%lf)",&x2,&y2);
    double dis = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    printf("This distance is: %.4f",dis);
}