Advertisement
halexandru11

este patrat

Mar 4th, 2021
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int dist2(int xa, int ya, int xb, int yb) {
  6.     return (xa-xb)*(xa-xb) + (ya-yb)*(ya-yb);
  7. }
  8.  
  9. int main() {
  10.     int x[4], y[4];
  11.     for(int i = 0; i < 4; ++i) {
  12.         cin >> x[i] >> y[i];
  13.     }
  14.  
  15.     int d1 = 0, d2 = 0;
  16.     for(int i = 0; i < 4; ++i) {
  17.         for(int j = i+1; j < 4; ++j) {
  18.             int d = dist2(x[i], y[i], x[j], y[j]);
  19.             if(d1 == 0 || d1 == d) {
  20.                 d1 = d;
  21.             }
  22.             else if(d2 == 0 || d2 == d) {
  23.                 d2 = d;
  24.             }
  25.             else {
  26.                 cout << "Nu\n";
  27.                 return 0;
  28.             }
  29.         }
  30.     }
  31.     cout << "Da\n";
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement