Advertisement
Eddie_1337

11 atestat

Dec 14th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. struct coordonate {
  8.     float x, y;
  9. } a[1001];
  10.  
  11. float distanta(int b, int c) {
  12.     return sqrt(pow((a[b].x - a[c].x), 2) + pow((a[b].y - a[c].y), 2));
  13. }
  14.  
  15. int main() {
  16.     int n = 1, q = 0, d = 0;
  17.     ifstream f("puncte.in");
  18.     ofstream g("puncte.out");
  19.     while (f >> a[n].x >> a[n].y) {
  20.         if (a[n].x > 0 && a[n].y > 0)
  21.             q++;
  22.         n++;
  23.     }
  24.     n--;
  25.     g << q << ' ';
  26.     for (int i = 1; i <= n - 1; i++)
  27.         for (int j = i + 1; j <= n; j++) {
  28.             q = distanta(i, j);
  29.             if (q > d)
  30.                 d = q;
  31.         }
  32.     g << d;
  33.     f.close(); g.close();
  34.     system("pause");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement