SHARE
TWEET

Untitled

a guest Sep 17th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     double x,phi , y, k;
  8.     int choice;
  9.     do {
  10.         phi = 0;
  11.         k = 0;
  12.         cout << "Input x:\n";
  13.         cin >> x;
  14.         cout << "Input y:\n";
  15.         cin >> y;
  16.         cout << "Input choice:";
  17.         cout << " 1 - 2x, 2 - x^2, 3 - x/3\n " << endl;
  18.         cin >> choice;
  19.         if (!cin) { cout << "Error type"; return -1; }
  20.         switch (choice)
  21.         {
  22.         case 1:
  23.             phi = 2 * x;
  24.             cout << "phi(x) = 2x";
  25.  
  26.             break;
  27.         case 2:
  28.             phi = pow(x, 2);
  29.             cout << "phi(x) = x^2";
  30.  
  31.             break;
  32.         case 3:
  33.             phi = x / 3;
  34.             cout << "phi(x) = x/3";
  35.  
  36.             break;
  37.         default:
  38.             cout << "Error!!!Wrong input!";
  39.            
  40.             return 0;
  41.             break;
  42.         }
  43.         if (fabs(x * y) > 10) {
  44.             k = log(fabs(phi) + fabs(y));
  45.             cout << "k = log(fabs(phi) + fabs(y)";
  46.         }
  47.         else if (fabs(x * y) < 10)
  48.         {
  49.             k = exp(phi + y);
  50.             cout << "k = exp(phi + y";
  51.         }
  52.         else
  53.         {
  54.             k = pow(fabs(phi), 2) + y;
  55.             cout << "k = pow(fabs(phi), 2) + y";
  56.         }
  57.         cout << "\nResult = " << k << endl;
  58.     } while (0);
  59.  
  60.     return 0;
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top