Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3.  
  4. struct Point {
  5. double x;
  6. double y;
  7. };
  8.  
  9. double distLength(double x1, double y1, double x2, double y2) {
  10. double xlength = x2 - x1, ylength = y2 - y1;
  11. return std::sqrt(xlength * xlength + ylength * ylength);
  12. }
  13.  
  14. struct Point midpoint(double x1, double y1, double x2, double y2) {
  15. struct Point point;
  16. point.x = (x1 + x2) / 2;
  17. point.y = (y1 + y2) / 2;
  18. return point;
  19.  
  20. }
  21. int main(void) {
  22. struct Point point = midpoint(-4.0, 2.0, 8.0, -3.0);
  23. std::cout << point.x << ", " << point.y << "\n";
  24. std::cout << distLength(-4.0, 2.0, 8.0, -3.0);
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement