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

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

发布时间: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;

}

阅读全文

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

热点内容
微信里面的文件储存在哪个目录 浏览:745
高仿苹果5s屏幕显示清楚吗 浏览:897
若有以下程序void 浏览:432
大数据主体有哪些 浏览:961
如何学习编程的优点 浏览:906
最新版本手机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

友情链接