刚学函数定义,求两点距离,看看怎么改

学习 时间:2026-03-30 15:43:55 阅读:4063
刚学函数定义,求两点距离,看看怎么改#include#include double sqrt(double y2,double y1,double x2,double x1){return sqrt(pow((y2 - y1),2) + pow((x2 - x1),2));}void main(){double length,y2,y1,x2,x1; printf("This program is calculate the two porint length\nPlease input :x1 y1 x2 y2 \n");scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);length=sqrt(y2,y1,x2,x1);printf("length:%lf\n",length);}老师说要,一楼的方法是Function Prototypes吗,还有Function Prototypes谁能解释一下。

最佳回答

傻傻的板凳

狂野的缘分

2026-03-30 15:43:55

sqrt()函数在math。h头文件里已经定义过了 不用再重新定义一遍了#include#include void main(){double length,y2,y1,x2,x1; printf("This program is calculate the two porint length\nPlease input :x1 y1 x2 y2 \n");scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);length=sqrt(pow((y2 - y1),2) + pow((x2 - x1),2));printf("length:%lf\n",length);}

最新回答共有2条回答

  • 勤奋的小蘑菇
    回复
    2026-03-30 15:43:55

    sqrt()函数在math。h头文件里已经定义过了 不用再重新定义一遍了#include#include void main(){double length,y2,y1,x2,x1; printf("This program is calculate the two porint length\nPlease input :x1 y1 x2 y2 \n");scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);length=sqrt(pow((y2 - y1),2) + pow((x2 - x1),2));printf("length:%lf\n",length);}

上一篇 征集一个英文名,中文名叫 靖(男),尽量要有意义.

下一篇 浣溪沙 苏轼 赏析"敲门试问野人家"一句具体表现出词人怎么样的神态