Advertisement
vadim_sharaf

Untitled

Oct 2nd, 2022
1,121
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <random>
  3. #include <cstdlib>
  4. #include <cmath>
  5. #include <ctime>
  6. using namespace std;
  7. int main() {
  8.     setlocale(LC_ALL, "ru");
  9.     double a, b, x, y, nx, ny, new_x, new_y;
  10.     int c = 0;
  11.     cout << "Введите параметры прямоугольника" << endl;;
  12.     cout << "длина: " ;
  13.     cin >> a;
  14.     cout << "ширина ";
  15.     cin >> b;
  16.     cout << "Введите координаты точки" << endl;
  17.     cout << "По оси абцисс: ";
  18.     cin >> x;
  19.     cout << "По оси ординат: ";
  20.     cin >> y;
  21.     y = abs(y);
  22.     x = abs(x);
  23.     if (x > a) {
  24.         c = x / a;
  25.         x = x - (c * a);
  26.     }
  27.     srand(static_cast <unsigned> (time(0))); // Получаем любую возможную координату начала окружности
  28.     double r2 = 0.0;
  29.     r2 += fmod(rand(), (a - b)) + 1;
  30.     r2 += (fmod(rand(), (a - b)) + 1) / 10.0;
  31.     r2 += (fmod(rand(), (a - b)) + 1) / 100.0;
  32.     r2 += (fmod(rand(), (a - b)) + 1) / 1000.0;
  33.     cout << "Координата цетра окружности по оси абцисс: " << r2 + b / 2 + c*a << endl;
  34.     if (y > b) { cout << "Не принадлежит"; }
  35.     else if ((x >= r2) && (x <= b + r2) ) {
  36.         nx = x - r2;
  37.         ny = y;
  38.         if (nx > b / 2) { new_x = nx / 2; }
  39.         else if (nx == b / 2) { new_x = 0; }
  40.         else { new_x = -(b / 2) + nx; }
  41.         if (ny > b / 2) { new_y = ny / 2; }
  42.         else if (ny == b / 2) { new_y = 0; }
  43.         else { new_y = -(b / 2) + ny; }
  44.         if (pow(new_x, 2) + pow(new_y, 2) <= pow(b / 2, 2)) {
  45.             cout << "Не принадлежит";
  46.         }
  47.         else {
  48.             cout << "Принадлежит";
  49.         }
  50.         return 0;
  51.     }
  52.     else { cout << "Принадлежит" << endl; }
  53. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement