ответ:
#include
int main() {
std: : cout < < "enter n > ";
int n = 1;
std: : cin > > n;
if (n < = 0) { std: : cout < < "you enter invalid number"; return -1; }
double y1 = 0.9, y2 = 1.1;
if (n == 1) return 0.9;
if (n == 2) return 1.1;
double y;
for (int i = 0; i < n - 2; i += 1) {
y = y1 / n + y2 / n / n;
y1 = y2; y2 = y;
}
return y;
ответ:
#include
int main() {
std: : cout < < "enter n > ";
int n = 1;
std: : cin > > n;
if (n < = 0) { std: : cout < < "you enter invalid number"; return -1; }
double y1 = 0.9, y2 = 1.1;
if (n == 1) return 0.9;
if (n == 2) return 1.1;
double y;
for (int i = 0; i < n - 2; i += 1) {
y = y1 / n + y2 / n / n;
y1 = y2; y2 = y;
}
return y;
}