刚学函数定义,求两点距离,看看怎么改#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
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/25 18:44:25
![刚学函数定义,求两点距离,看看怎么改#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(](/uploads/image/z/7613862-6-2.jpg?t=%E5%88%9A%E5%AD%A6%E5%87%BD%E6%95%B0%E5%AE%9A%E4%B9%89%2C%E6%B1%82%E4%B8%A4%E7%82%B9%E8%B7%9D%E7%A6%BB%2C%E7%9C%8B%E7%9C%8B%E6%80%8E%E4%B9%88%E6%94%B9%23include%23include+double+sqrt%28double+y2%2Cdouble+y1%2Cdouble+x2%2Cdouble+x1%29%7Breturn+sqrt%28pow%28%28y2+-+y1%29%2C2%29+%2B+pow%28%28x2+-+x1%29%2C2%29%29%3B%7Dvoid+main%28%29%7Bdouble+length%2Cy2%2Cy1%2Cx2%2Cx1%3B+printf%28%22This+program+is+calculate+the+two)
刚学函数定义,求两点距离,看看怎么改#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
刚学函数定义,求两点距离,看看怎么改
#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谁能解释一下。
刚学函数定义,求两点距离,看看怎么改#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
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);
}
定义函数的时候,不能用sqrt了。换一个函数名就行了。