刚学函数定义,求两点距离,看看怎么改#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/11/28 12:19:00
刚学函数定义,求两点距离,看看怎么改#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了。换一个函数名就行了。