#include<stdio.h>
#include<math.h>
struct point{
int x;
int y;
};
int main(){
struct point p1;
struct point p2;
scanf("%d %d %d %d", &p1.x , &p1.y , &p2.x , &p2.y);
double distance;
distance = sqrt( pow(p1.x-p2.x,2) + pow(p1.y-p2.y,2) );
printf("distance = %.2lf" , distance);
return 0;
}
必须要用pow函数吗,sqrt函数肯定是要用的开平方,为什么
distance = sqrt( (p1.x-p2.x)^2 + (p1.y-p2.y)^2 ); 算出来的结果是不对的,而且是distance = -han什么的。