Задача в С++.P=(1-1/2^2)(1-1/3^2)...(1-1/n^2),n>1.

udovika udovika    3   27.12.2020 20:13    2

Ответы
26271123 26271123  26.01.2021 20:16

#include <iostream>

#include <vector>

#include <cstdlib>

#include <ctime>

#include <algorithm>

using namespace std;

int main() {

float n;

cin >> n;

if (n <= 1) {

 cout << "wrong data";

 return 0;

}

float P = (1-1/2*2)*(1-1/3*3);

for (int i = 3; i <= n; ++i) {

 P *= (1 - 1 / (n * n));

}

cout << P;

}

ПОКАЗАТЬ ОТВЕТЫ
Другие вопросы по теме Информатика