Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- double x;
- double y;
- bool isTrue;
- bool isNotCorrect;
- x = 0.0;
- y = 0.0;
- isTrue = false;
- cout << "Это программа считает, принадлежит ли точка множеству D" << endl;
- do {
- cout << "Введите координату x от -1.00 до 1.00" << endl;
- isNotCorrect = false;
- cin >> x;
- if (cin.fail())
- {
- isNotCorrect = true;
- cin.clear();
- while (cin.get() != '\n');
- cout << "Пожалуйста, вводите числа" << endl;
- }
- }
- while(isNotCorrect);
- do {
- cout << "Введите координату y от -1.00 до 1.00" << endl;
- isNotCorrect = false;
- cin >> y;
- if (cin.fail())
- {
- isNotCorrect = true;
- cin.clear();
- while (cin.get() != '\n');
- cout << "Пожалуйста, вводите числа" << endl;
- }
- }
- while(isNotCorrect);
- if( (((y == -1 || y == 0) && (x == 1 || x == -1))) || (y == 1 && x == 0)) // точки краёв зоны D
- {
- isTrue = true;
- }
- else
- {
- if (y < 0 && y > -1) // точки под осью X
- {
- if(x > -1 && x < 1)
- {
- isTrue = true;
- }
- }
- else // точки над осью x
- {
- if ((abs(y) + abs(x) < 1) || (abs(y) + abs(x) == 1))
- {
- isTrue = true;
- }
- }
- }
- if(isTrue)
- {
- cout << "Точка принадлежит области D" << endl;
- }
- else
- {
- cout << "Точка не принадлежит области D" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment