Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <random>
- #include <cstdlib>
- #include <cmath>
- #include <ctime>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "ru");
- double a, b, x, y, nx, ny, new_x, new_y;
- int c = 0;
- cout << "Введите параметры прямоугольника" << endl;;
- cout << "длина: " ;
- cin >> a;
- cout << "ширина ";
- cin >> b;
- cout << "Введите координаты точки" << endl;
- cout << "По оси абцисс: ";
- cin >> x;
- cout << "По оси ординат: ";
- cin >> y;
- y = abs(y);
- x = abs(x);
- if (x > a) {
- c = x / a;
- x = x - (c * a);
- }
- srand(static_cast <unsigned> (time(0))); // Получаем любую возможную координату начала окружности
- double r2 = 0.0;
- r2 += fmod(rand(), (a - b)) + 1;
- r2 += (fmod(rand(), (a - b)) + 1) / 10.0;
- r2 += (fmod(rand(), (a - b)) + 1) / 100.0;
- r2 += (fmod(rand(), (a - b)) + 1) / 1000.0;
- cout << "Координата цетра окружности по оси абцисс: " << r2 + b / 2 + c*a << endl;
- if (y > b) { cout << "Не принадлежит"; }
- else if ((x >= r2) && (x <= b + r2) ) {
- nx = x - r2;
- ny = y;
- if (nx > b / 2) { new_x = nx / 2; }
- else if (nx == b / 2) { new_x = 0; }
- else { new_x = -(b / 2) + nx; }
- if (ny > b / 2) { new_y = ny / 2; }
- else if (ny == b / 2) { new_y = 0; }
- else { new_y = -(b / 2) + ny; }
- if (pow(new_x, 2) + pow(new_y, 2) <= pow(b / 2, 2)) {
- cout << "Не принадлежит";
- }
- else {
- cout << "Принадлежит";
- }
- return 0;
- }
- else { cout << "Принадлежит" << endl; }
- }
Advertisement
Advertisement