fork(2) download
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. double y(double x);
  8.  
  9. int main(int argc, char* argv[])
  10. {
  11. double a = 0.1, b = 1.0, h = 0.1;
  12. double sum, prev;
  13. int k;
  14.  
  15. cout << "k = "; cin >> k;
  16.  
  17. for (double x = a; x < b + h / 2; x += h) {
  18. //start values
  19. sum = prev = pow(x,3) / 3;
  20. for (int n = 2; n <= k; ++n) {
  21. prev *= -1 * (x * x);
  22. sum += prev / (4 * n * n - 1);
  23. }
  24.  
  25. cout << "y(x) = " << y(x) << " AND s(x) = " << sum << endl;
  26. }
  27.  
  28. return 0;
  29. }
  30.  
  31. double y(double x)
  32. {
  33. return (1 + x * x) / 2 * atan(x) - x / 2;
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:20: fatal error: stdafx.h: No such file or directory
 #include "stdafx.h"
                    ^
compilation terminated.
stdout
Standard output is empty