Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iostream>
- struct Point {
- double x;
- double y;
- };
- double distLength(double x1, double y1, double x2, double y2) {
- double xlength = x2 - x1, ylength = y2 - y1;
- return std::sqrt(xlength * xlength + ylength * ylength);
- }
- struct Point midpoint(double x1, double y1, double x2, double y2) {
- struct Point point;
- point.x = (x1 + x2) / 2;
- point.y = (y1 + y2) / 2;
- return point;
- }
- int main(void) {
- struct Point point = midpoint(-4.0, 2.0, 8.0, -3.0);
- std::cout << point.x << ", " << point.y << "\n";
- std::cout << distLength(-4.0, 2.0, 8.0, -3.0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement