新手学C语言,简单的问题,求大神解答,谢谢啦

2024-12-23 04:00:47
推荐回答(1个)
回答1:

#include
#include
double distance(double x1,double y1,double x2,double y2);
int main(void)
{
double x1,x2,y1,y2,d;
printf("Input x1,y1:");
scanf("%.2f%.2f",&x1,&y1);
printf("Input x2,y2:");
scanf("%.2f%.2f",&x2,&y2);
d=distance(x1,y1,x2,y2);

printf("distance=%.2f",d);
return 0;
}
double distance(double x1,double y1,double x2,double y2)
{
double s;
s=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
return s;
}

头文件放在最开始,
distance函数调用错误写成了dist
sqrt也写错了,写成了sprt
函数声明要加类型