Advertisement
PhanNguyen

Bai5Lab5KTLT

Apr 8th, 2015
213
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 <math.h>
  3. using namespace std;
  4. int main()
  5. {
  6.     struct toado
  7.     {
  8.         double x;
  9.         double y;
  10.     };
  11.     toado h[5];
  12.     double kc(0);
  13.     int i, j, a, b;
  14.     for (i = 0; i < 5; i++)
  15.     {
  16.         cout << "Nhap toa do diem thu " << i+1 << endl;
  17.         cout << "x = "; cin >> h[i].x; cout << "y = "; cin >> h[i].y;
  18.     }
  19.     for (i = 0; i < 5; i++)
  20.     {
  21.         for (j = i + 1; j < 5; j++)
  22.         {
  23.             if (kc < sqrt(pow(h[i].x - h[j].x, 2) + pow(h[i].y - h[j].y, 2)))
  24.             {
  25.                 kc = sqrt(pow(h[i].x - h[j].x, 2) + pow(h[i].y - h[j].y, 2));
  26.                 a = i+1; b = j+1;
  27.                
  28.             }
  29.         }
  30.     }
  31.     cout << a << " " << b << endl;
  32.     system("pause");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement