fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. double sum, Del0;
  8. int x, n, max;
  9.  
  10. setlocale(LC_ALL, "");
  11.  
  12. cout << "Введите max: " << endl;
  13. cin >> max;
  14.  
  15. cout << "Введите De10: " << endl;
  16. cin >> Del0;
  17.  
  18. x = 3, 14 * 3, 14 / 12;
  19.  
  20. n = 1;
  21. sum = 0;
  22. while (abs(sum - x) < Del0) {
  23. for (n = 1; n <= max; n++) {
  24. sum = sum + pow(-1, n + 1) * 1 / pow(n, 2);
  25. cout << "При n = " << n << " сумма равна " << sum << endl;
  26. }
  27. }
  28.  
  29. cout << "Количество элементов: " << n << endl;
  30.  
  31. }
Success #stdin #stdout 0s 4228KB
stdin
500
0.01
stdout
Введите max: 
Введите De10: 
Количество элементов: 1