计算两点间的距离

思路:用pow函数计算,并且分开两步,比较简洁

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

int main()
{
double x,y,m,n,c;
while(scanf("%lf %lf %lf %lf",&x,&y,&m,&n)!=EOF)
{
c=pow(x-m,2)+pow(y-n,2);
c=pow(c,0.5);
printf("%.2lf ",c);
}

return 0;
}

原文地址:https://www.cnblogs.com/zhs314159/p/10322754.html