-->
当前位置:首页 > 题库

PROGRAMMING:The application of friend function to calculate the distance from point to line

Luz5年前 (2021-05-10)题库395
Calculate the distance from the point to the line. First, we design a point class, which has two private data members X and y, representing the coordinates of the point. The other class is line, which has three private data members a, B and C, representing the linear equation AX + by + C = 0. In both classes, a friend function dist is used to calculate the distance between a point and a line. The calculation formula of the distance d from the point (x.y) to the straight line ax + by + C = 0 is as follows:
![ No title. BMP] (~ / 244123e7-2cfb-42cd-b024-4bab3b7d813e. BMP)
Syntax points: the characteristics of friend function.
This is a programming problem template. Please write the title description here. For example: this topic requires reading in 2 integers a and B, and then output their sum.
###Input format:
Enter two lines. Enter two integers in the first line to represent the values of point coordinates x and y
In the second line, input three parameters of the line, which represent the three washes a, B, C of the linear equation
###Output format:
Calculate the distance between the point and the line, and reserve two decimal places.
###Input example:
Here is a set of inputs. For example:
```in
5 5
2 4 3
```
###Output example:
The corresponding output is given here. For example:
```out
The distance is: 7.38
```







answer:If there is no answer, please comment