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;
}
Объяснение:
import math
print("Введите кол-во чисел в последовательности:")
leangth_nums = input();
if int(leangth_nums) <= 1000:
i = 0;
nums_arr_five = [];
print("Введите числа, когда вы решите что чисел хватит напишите stop")
while i <= 999:
num_input = input()
if (num_input == "stop"):
break;
else:
if (int(num_input) % 5 == 0):
if (int(num_input) < 30000):
nums_arr_five.append(int(num_input))
i+=1
else:
print("num > 30000")
else:
i += 1
continue
print(max(nums_arr_five))
else:
print("Error leanth_nums is have lean. > 1000")
Объяснение:
int main ()
{
const int SIZE = 12;
int array [SIZE] = {10};
for (int i = 1; i < SIZE; i++)//Task1
array[i] = array[i - 1] + 2;
//Task2
array[0] = 1;
for (int i = 1; i < SIZE; i++)
array[i] = array[i - 1] * 2;
//Task3
int Data[SIZE - 2] = {};
for (int i = 0; i < SIZE - 2; i++)
scanf ("%d", &Data[i]);
for (int i = 0; i < SIZE; i++)
printf ("[%d] = %d", i, Data[i]);
//task 4 = task 3, но SIZE = 7
}