Advertisement
Guest User

6ta zad

a guest
Nov 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const double centerX = 0;
  5. const double centerY = 0;
  6.  
  7. bool CheckFirstFigure(double x, double y);
  8.  
  9. int main()
  10. {
  11.     double x, y;
  12.     cin >> x >> y;
  13.  
  14.     if (CheckFirstFigure(x, y))
  15.     {
  16.         cout << "Black";
  17.     }
  18.     else if (abs((x - centerX)*(x - centerX) + (y - centerY) * (y - centerY) - 4.0) < 0.01)
  19.     {
  20.         cout << "Undefined";
  21.     }
  22.     else if (abs((x - centerX) * (x - centerX) + (y - centerY) * (y - centerY) - 9.0) < 0.01)
  23.     {
  24.         cout << "Undefined";
  25.     }
  26.     else if ((x - centerX) * (x - centerX) + (y - centerY) * (y - centerY) > 4.0 && (x - centerX) * (x - centerX) + (y - centerY) * (y - centerY) < 9.0)
  27.     {
  28.         cout << "Black";
  29.     }
  30.     else if ((x - centerX) * (x - centerX) + (y - centerY) * (y - centerY) < 4.0 && !(CheckFirstFigure(x, y)))
  31.     {
  32.         cout << "White";
  33.     }
  34.     else
  35.     {
  36.         cout << "Outside";
  37.     }
  38.  
  39.     return 0;
  40. }
  41.  
  42. bool CheckFirstFigure(double x, double y)
  43. {
  44.     if ((x >= -1.0 && x <= 1.0) && abs(y - 1.0) < 0.001)
  45.     {
  46.         return true;
  47.     }
  48.     else if ((y >= -1.0 && y <= 1.0) && abs(x - 1.0) < 0.001)
  49.     {
  50.         return true;
  51.     }
  52.     else
  53.     {
  54.         return false;
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement