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

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

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

}

阅读全文

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

热点内容
ps3文件分割视频 浏览:280
微信图片一键转发软件 浏览:331
如何判断s200plc编程电缆 浏览:691
太原编程培训班哪个好 浏览:171
树叶吹奏教程 浏览:6
社交app带来了哪些社会问题 浏览:394
如何安装爱宝8800数据采集器 浏览:712
文件保存了怎么找不到了 浏览:476
彩票网站怎么辨真假 浏览:840
pr找不到该文件 浏览:963
java移除panel 浏览:354
jsp填充jsp 浏览:166
海关外贸大数据在哪里查 浏览:381
思特奇java笔试题 浏览:121
葫芦侠在手机中的文件名 浏览:813
plc编程应该怎么收钱 浏览:584
c语言中源文件由什么组成 浏览:890
linuxhttpdphp配置文件 浏览:607
拆单数据要怎么保存 浏览:17
mac电脑怎样压缩文件到100m 浏览:645

友情链接