Advertisement
realanton12345

Task 3

Dec 28th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. void process(int choice, float x, float y) {
  7.     float f = 0.0;
  8.     float result = abs(x * y);
  9.     float c = 0.0;
  10.     switch (choice) {
  11.         case 1: f = sinh(x); break;
  12.         case 2: f = pow(x, 2); break;
  13.         case 3: f = exp(x); break;
  14.         default: break;
  15.     }
  16.     cout << "Function = " << f << endl;
  17.     cout << "Result = " << result << endl;
  18.     if (result > 10) {
  19.         c = abs(log(f)) + abs(y);
  20.     } else if (result < 10) {
  21.         c = exp(f + y);
  22.     } else if (result == 10) {
  23.         c = pow(abs(f), 1 / 3) + y;
  24.     }
  25.     cout << c << endl;
  26. }
  27.  
  28. int main()
  29. {
  30.     cout << "LR2" << endl;
  31.     int choice = -1;
  32.     float x;
  33.     float y;
  34.     cout << "1. sh(x)" << endl;
  35.     cout << "2. x^2" << endl;
  36.     cout << "3. e^x" << endl;
  37.     cout << "Choose the function: ";
  38.     cin >> choice;
  39.  
  40.     if (choice >= 1 && choice <= 3) {
  41.         cout << "Enter x: ";
  42.         cin >> x;
  43.         cout << "Enter y: ";
  44.         cin >> y;
  45.         process(choice, x, y);
  46.     }
  47.  
  48.     system("pause");
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement