Task 3.
Write a program that reads the coordinates of max. 10 points (pairs of x and y) and
saves those into a two-dimensional array: double points[10][2] (the array can store 10
pairs of x and y coordinates, i.e., data for 10 points). Then the program calculates the
length of the distance traveled through the points (from the first point to the last point).
The program uses functions for reading the coordinates of the points to an array…
readPoints(double [][2], int size)
… and for printing the points…
void printPoints(double [][2], int size)
… and for calculating the distance…
double calculateDistance(double x1, double y1, double x2, double y2)
The distance between two points (x1, y1) ja (x2, y2) is calculated by using the formula:
distance = 根號下(x1-x2)^2+(y1-y2)^2
任務3。
寫一個程式,讀取坐標的最大值。10分(x和y對)和
保存到二維陣列中:雙點[10][2](陣列可存盤10
x和y坐標對,即10點的資料)。然后程式計算
通過點(從第一點到最后一點)的距離的長度。
該程式使用函式讀取點的坐標到一個陣列…
readPoints(double [][2], int size)
和列印要點…
printPoints(double [][2], int size)
為了計算距離…
double calculateDistance(double x1, double y1, double x2, double y2)
兩點(x1, y1) ja (x2, y2)的距離計算公式為:
距離=根號下(x1-x2)^2+(y1-y2)^2
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/227417.html
標籤:C語言
上一篇:原始碼超短,求助
