Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define _USE_MATH_DEFINES
- #include <math.h>
- using namespace std;
- double funk(double, double);
- double max(double, double, double);
- int n;
- /*double* mas1 = nullptr;
- void shift1(int, double);*/
- double* mas1 = nullptr;
- double shift1(int, double);
- bool pal(int);
- int main()
- {
- setlocale(LC_ALL, "Russian");
- long n;
- char ex = 'n';
- do {
- cout << "Введите номер задания: " << endl;
- char task;
- /*cin.ignore(100, '\n');*/
- cin >> task;
- switch (task)
- {
- case '1': {
- double z, x, y;
- cout << "Enter x and y: ";
- cin >> x >> y;
- cout << endl;
- if ((x != y) && (y > 0)&&(y<=1)&&(x>=-1)&&(x<=1))
- {
- z = funk(y, x) + fabs((sqrt(3 * funk(x, y))) / ((x - y) * exp(2 * x)));
- cout << funk(y, x) << endl;
- cout << funk(x, y) << endl;
- cout << "Your result: " << z;
- }
- else
- {
- cout << "Error";
- }
- break;
- }
- case '2': {
- cout << "Enter a, b, c: " << endl;
- double a, b, c;
- cin >> a >> b >> c;
- cout << "Your result: " << max((a * a + b) / (2 * a * b * b), (b * b - a * c) / (c + 2 * b), (c * a) / (a + sqrt(b))) + max((a - pow(b, 1.0 / c)) / b, (pow(a, b) - pow(b, c)) / (pow(pow(a, a) + c, 0.25)), 1.0 / a) << endl;
- break;
- }
- case '3': {
- /*cout << "enter n " << endl;
- cin >> n;
- mas1 = new double[n];
- for (int i = 0; i < n; i++)
- cin >> mas1[i];
- double t;
- if (n % 2 != 0)
- {
- t = mas1[n - 1];
- }
- else
- {
- t = mas1[n - 2];
- }
- shift1(n, t);
- for (int i = 0; i < n; i++)
- cout << mas1[i] << " ";
- delete[] mas1;*/
- cout << "enter n " << endl;
- cin >> n;
- mas1 = new double[n];
- for (int i = 0; i < n; i++)
- cin >> mas1[i];
- double t;
- if (n % 2 != 0)
- {
- t = mas1[n - 1];
- }
- else
- {
- t = mas1[n - 2];
- }
- shift1(n, t);
- for (int i = 0; i < n; i++)
- cout << mas1[i] << " ";
- delete[] mas1;
- break;
- }
- case '4': {
- int k;
- int rez = 0;
- cout << "Enter k: " << endl;
- cin >> k;
- for (int i = 1; i <= k; i++)
- {
- if (pal(i) == true)
- {
- rez++;
- }
- }
- cout << "Your result: " << rez << endl;
- break;
- }
- default: {cout << "Нет такой задачи.\n"; } break;
- }
- cout << "Если вы хотите выйти, нажмите \'y\', в противном случае-любую другую клавишу" << endl;
- cin.ignore(100, '\n');
- cin >> ex;
- } while (ex != 'y');
- return 0;
- }
- double funk(double t, double p)
- {
- double funkt = asin(3 * t) - sin(2 * p);
- return funkt;
- }
- double max(double x, double y, double z)
- {
- double max1, max2;
- if (x > y)
- {
- max1 = x;
- }
- else
- {
- max1 = y;
- }
- if (max1 > z)
- {
- max2 = max1;
- }
- else
- {
- max2 = z;
- }
- return max2;
- }
- /*void shift1(int a, double b)
- {
- if (n % 2 != 0)
- {
- for (int i = a - 1; i > 1; i -= 2)
- mas1[i] = mas1[i - 2];
- mas1[0] = b;
- //ret
- }
- else
- {
- for (int i = a - 2; i > 1; i -= 2)
- mas1[i] = mas1[i - 2];
- mas1[0] = b; //не исправлять строку
- //ret
- }
- }*/
- double shift1(int a, double b)
- {
- if (a % 2 != 0)
- {
- for (int i = a-1; i > 1; i -= 2)
- mas1[i] = mas1[i - 2];
- mas1[0] = b;
- }
- else
- {
- for (int i = a - 2; i > 1; i -= 2)
- mas1[i] = mas1[i - 2];
- mas1[0] = b; //не исправлять строку
- return 0;
- }
- }
- bool pal(int p)
- {
- bool t;
- int k = p;
- int b = 0;
- while (k > 0)
- {
- b = b * 10 + k % 10;
- k = k / 10;
- }
- if (p == b)
- {
- t = true;
- }
- else
- {
- t = false;
- }
- return t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement