/*来试一试下面的。dist函数的类型应定义成double型,不能是int型。*/
#include
#include
double dist(double x1,double x2,double y1,double y2)
{
double distance;
distance=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
return distance;
}
int main(void)
{
double x1,x2,y1,y2,distance;
printf("Input(x1,y1): ");
scanf("%lf %lf",&x1,&y1);
printf("Input(x2,y2): ");
scanf("%lf %lf",&x2,&y2);
distance=dist(x1,x2,y1,y2);
printf("distance=%.2f,%f\n",distance,a);
return 0;
}