导航:首页 > 编程知识 > 如何用编程计算两点间距离

如何用编程计算两点间距离

发布时间:2023-03-03 03:47:25

A. 求C语言程序:计算两点间的距离

代码如下:

#include<stdio.h>

#include<math.h>

struct point

{

double x;

double y;

};

struct point readPoint();

double distance(struct point p1,struct point p2);

int main(void)

{

struct point a,b;

double dis;

printf(" distance! ");

printf("please input the point(for example:1.0,2.0):");

a=readPoint();

printf(" please input the point(for example:1.0,2.0):");

b=readPoint();

dis=distance(a,b);

printf(" the distance is:%.2f ",dis);

return 0;

}

struct point readPoint()

{

struct point p;

scanf("%lf,%lf",&p.x,&p.y);

return p;

}

double distance(struct point p1,struct point p2)

{

double d;

d=sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));

return d;

}

阅读全文

与如何用编程计算两点间距离相关的资料

热点内容
最新版本手机qq 浏览:463
简述在word 浏览:528
qq怎么清楚历史记录防止被盗 浏览:263
发送手机里的录音文件在哪里 浏览:866
js获取下一个兄弟元素 浏览:293
js模板引擎原理 浏览:72
linuxo文件运行 浏览:713
什么免费备份数据 浏览:342
测量大师导入底图找不到文件 浏览:313
小红伞安装程序要求版本6 浏览:799
全民k歌pcm文件夹 浏览:224
c图片写入数据库 浏览:466
c串口程序 浏览:500
中农金融注册app有哪些 浏览:629
回收站文件清理不在电脑上有痕迹 浏览:886
dx版本更新 浏览:738
主机集群教程 浏览:939
苹果6英版好不好 浏览:959
nodejs抓取网站音频 浏览:772
app上下载的软件在哪里 浏览:36

友情链接