x2311

Untitled

Jan 12th, 2022
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. const int N = 3;
  5.  
  6. int main() {
  7.     double X[N];
  8.     double Y[N];
  9.  
  10.     for (int i = 0; i < N; ++i) {
  11.         cout << endl;
  12.         cout << "X: ";
  13.         cin >> X[i];
  14.         cout << endl;
  15.         cout << "Y: ";
  16.         cin >> Y[i];
  17.     }
  18.     int sum = 0;
  19.     int f1 = 0;
  20.     int f2 = 0;
  21.     for (int i = 0; i < N; ++i) {
  22.         for (int j = 0; j < N; ++j) {
  23.             int n = (X[j] - X[i]) + (Y[j] - Y[i]);
  24.             if (i != j && sum < n) {
  25.                 sum = n;
  26.                 f1 = i + 1;
  27.                 f2 = j + 1;
  28.             }
  29.         }
  30.     }
  31.  
  32.     cout << endl;
  33.     cout << endl;
  34.     cout << "X[";
  35.     cout << f1;
  36.     cout << "]";
  37.     cout << "\tY[";
  38.     cout << f1;
  39.     cout << "]";
  40.     cout << " === ";
  41.     cout << "X[";
  42.     cout << f2;
  43.     cout << "]";
  44.     cout << "\tY[";
  45.     cout << f2;
  46.     cout << "]";
  47.  
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment