導航:首頁 > 編程知識 > 如何用編程計算兩點間距離

如何用編程計算兩點間距離

發布時間: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

友情鏈接