Advertisement
Spocoman

01. Center Point

Oct 26th, 2023 (edited)
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void closestToTheCenter(double x1, double x2, double y1, double y2) {
  6.     if (abs(x1 * x1 + y1 * y1) < abs(x2 * x2 + y2 * y2)) {
  7.         cout << "(" << x1 << ", " << y1 << ")\n";
  8.     }
  9.     else {
  10.         cout << "(" << x2 << ", " << y2 << ")\n";
  11.     }
  12. }
  13.  
  14. int main() {
  15.     double x1, y1, x2, y2;
  16.     cin >> x1 >> y1 >> x2 >> y2;
  17.  
  18.     closestToTheCenter(x1, x2, y1, y2);
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement