1)
#include <iostream>
#include <math.h>
using namespace std;
int main() {
setlocale(LC_ALL, "Russian");
float x, y;
cout << "Введите х:";
cin >> x;
if (x <= 0) {
y = 3 * sin(x) - pow(cos(x), 2) * x;
cout << y;
}
else if (x > 0) {
y = sqrt(1 + pow(x, 2));
cout << y;
}
else {
y = log(x + 5);
cout << y;
}
return 0;
}
2)
#include <iostream>
#include <math.h>
using namespace std;
int main() {
setlocale(LC_ALL, "Russian");
float x, f;
cout << "Введите х:";
cin >> x;
if (x < 0) {
f = 3/pow((x-3),2);
cout << f;
}
else if (0<=x<=2) {
f = x-1;
cout << f;
}
else if(x>2) {
f = log(x);
cout << f;
}
return 0;
}
Объяснение:
1)
#include <iostream>
#include <math.h>
using namespace std;
int main() {
setlocale(LC_ALL, "Russian");
float x, y;
cout << "Введите х:";
cin >> x;
if (x <= 0) {
y = 3 * sin(x) - pow(cos(x), 2) * x;
cout << y;
}
else if (x > 0) {
y = sqrt(1 + pow(x, 2));
cout << y;
}
else {
y = log(x + 5);
cout << y;
}
return 0;
}
2)
#include <iostream>
#include <math.h>
using namespace std;
int main() {
setlocale(LC_ALL, "Russian");
float x, f;
cout << "Введите х:";
cin >> x;
if (x < 0) {
f = 3/pow((x-3),2);
cout << f;
}
else if (0<=x<=2) {
f = x-1;
cout << f;
}
else if(x>2) {
f = log(x);
cout << f;
}
return 0;
}
Объяснение: