在C语言中怎样定义一个函数为“distance”?

如题所述

第1个回答  2020-02-13
distance是什么意思?
还是你要问函数定义?
在预处理命令后面,也就是带#的行后;

void
distance();
然后main函数外写
void
distance()
{
//你的函数内容
}
在main函数里就可以调用
distance();
第2个回答  2019-12-17
long
distance(point
a,
point
b)
{
long
d
=
0;
d
=
(long)sqrt((a.x-b.x)*(a.x-b.x)
+
(a.y-b.y)*(a.y-b.y));
return
d;
}
这个函数接受两个point类型的参数a和b,返回a和b之间类型是long的距离d。
相似回答
大家正在搜