Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- double x,phi , y, k;
- int choice;
- do {
- phi = 0;
- k = 0;
- cout << "Input x:\n";
- cin >> x;
- cout << "Input y:\n";
- cin >> y;
- cout << "Input choice:";
- cout << " 1 - 2x, 2 - x^2, 3 - x/3\n " << endl;
- cin >> choice;
- if (!cin) { cout << "Error type"; return -1; }
- switch (choice)
- {
- case 1:
- phi = 2 * x;
- cout << "phi(x) = 2x";
- break;
- case 2:
- phi = pow(x, 2);
- cout << "phi(x) = x^2";
- break;
- case 3:
- phi = x / 3;
- cout << "phi(x) = x/3";
- break;
- default:
- cout << "Error!!!Wrong input!";
- return 0;
- break;
- }
- if (fabs(x * y) > 10) {
- k = log(fabs(phi) + fabs(y));
- cout << "k = log(fabs(phi) + fabs(y)";
- }
- else if (fabs(x * y) < 10)
- {
- k = exp(phi + y);
- cout << "k = exp(phi + y";
- }
- else
- {
- k = pow(fabs(phi), 2) + y;
- cout << "k = pow(fabs(phi), 2) + y";
- }
- cout << "\nResult = " << k << endl;
- } while (0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement