Advertisement
STANAANDREY

puncte

Nov 6th, 2019
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. typedef struct
  6. {
  7.     float x, y;
  8. } PUNCT;
  9.  
  10. int main()
  11. {
  12.     float maxi = 0.0;
  13.     PUNCT p[100];
  14.     int n, papx = 0;
  15.     cin >> n;
  16.     for (int i = 0; i < n; i++)
  17.         cin >> p[i].x >> p[i].y;
  18.  
  19.     for (int i = 0; i < n; i++)
  20.         if (!p[i].y)
  21.             papx++;
  22.     cout << "apartin lui Ox: " << papx << endl;
  23.  
  24.     for (int i = 0; i < n; i++)
  25.         for (int j = 0; j < n; j++)
  26.             if (i != j)
  27.             {
  28.                 float d = sqrt((p[i].x - p[j].x) * (p[i].x - p[j].x) + (p[i].y - p[j].y) * (p[i].y - p[j].y));
  29.                 if (maxi < d)
  30.                     maxi = d;
  31.             }
  32.  
  33.     cout << "distanta maxima: " << maxi;
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement