Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- void process(int choice, float x, float y) {
- float f = 0.0;
- float result = abs(x * y);
- float c = 0.0;
- switch (choice) {
- case 1: f = sinh(x); break;
- case 2: f = pow(x, 2); break;
- case 3: f = exp(x); break;
- default: break;
- }
- cout << "Function = " << f << endl;
- cout << "Result = " << result << endl;
- if (result > 10) {
- c = abs(log(f)) + abs(y);
- } else if (result < 10) {
- c = exp(f + y);
- } else if (result == 10) {
- c = pow(abs(f), 1 / 3) + y;
- }
- cout << c << endl;
- }
- int main()
- {
- cout << "LR2" << endl;
- int choice = -1;
- float x;
- float y;
- cout << "1. sh(x)" << endl;
- cout << "2. x^2" << endl;
- cout << "3. e^x" << endl;
- cout << "Choose the function: ";
- cin >> choice;
- if (choice >= 1 && choice <= 3) {
- cout << "Enter x: ";
- cin >> x;
- cout << "Enter y: ";
- cin >> y;
- process(choice, x, y);
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement