Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- double TakeNum(const int MIN, const int MAX) {
- const string ERROR_CHOISE = "Проверьте корректность введнных данных!\n";
- bool isIncorrect;
- double num;
- do {
- isIncorrect = false;
- cin >> num;
- if (cin.fail()) {
- isIncorrect = true;
- cout << ERROR_CHOISE;
- cin.clear();
- while (cin.get() != '\n');
- }
- if (!isIncorrect && cin.get() != '\n') {
- cin.clear();
- while (cin.get() != '\n');
- cout << ERROR_CHOISE;
- isIncorrect = true;
- }
- if (!isIncorrect && (num < MIN || num > MAX)) {
- isIncorrect = true;
- cout << ERROR_CHOISE;
- }
- } while (isIncorrect);
- return num;
- }
- int main() {
- setlocale(LC_ALL, "Rus");
- double x, y;
- int R2 = 2, R1 = 1;
- cout << "Вариант 6\n";
- cout << "Задание 1.6\n";
- cout << "Введите X\n";
- x = TakeNum(-10000, 10000);
- if (x > 7)
- x *= 2;
- cout << "X = " << x << '\n';
- cout << "Задание 2.6 \n";
- cout << "Введите X, Y\n";
- x = TakeNum(-10000, 10000);
- y = TakeNum(-10000, 10000);
- if ((pow(x, 2) + pow(y, 2)) == 1)
- cout << "На границе\n";
- else if((pow(x, 2) + pow(y, 2)) < 1)
- cout << "Да\n";
- else
- cout << "Нет\n";
- cout << "Задание 3.6\n";
- cout << "Введите X\n";
- x = TakeNum(-10000, 10000);
- if (x <= -1)
- cout << (y = cos(pow(x, 2))) << '\n';
- else if (x >= 3)
- cout << (y = 2 / x) << '\n';
- else
- cout << (y = -fabs(x)) << '\n';
- cout << "Задание 4.6\n";
- cout << "Введите X\n";
- x = TakeNum(-10000, 10000);
- if (x <= -6 && x >= -7)
- cout << "y = 1";
- else if (x > -6 && x <= -4)
- cout << "y = " << (y = -0.5 * x - 2);
- else if (x > -4 && x <= 0)
- cout << "y = " << (y = sqrt(R2 * R2 - pow((-2 - x), 2)));
- else if (x > 0 && x < 2)
- cout << "y = " << (y = -sqrt(R1 * R1 - pow((1 - x), 2)));
- else if (x >= 2 && x <= 3)
- cout << "y = " << (y = -x + 2);
- else
- cout << "Нет значений";
- }
Advertisement
Add Comment
Please, Sign In to add comment