Advertisement
Courbe_Impliquee

gaylor

Dec 19th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cmath>
  5. #include "stdio.h"
  6. using namespace std;
  7. int main()
  8. {
  9. float xn, xk, dx, e, s, sum, x;
  10. int n, flag;
  11. printf ("Vvedite xn, xk, dx: ");
  12. scanf_s ("%f%f%f%f",&xn,&xk,&dx,&e);
  13. printf ( "-------------------------------------------------\n");
  14. printf ( "| x | f | exp(-x) | n |\n");
  15. printf ( "-------------------------------------------------\n");
  16.  
  17. for (x = xn; x <= xk; x += dx)
  18. {
  19. n = 1;
  20. sum = 1;
  21. s = -x;
  22. sum += s;
  23. while (fabs(s)>e)
  24. {
  25. s *= -x/(n+1);
  26. sum += s;
  27. n++;
  28. }
  29. printf(" %8.5f | %8.5f | %8.5f | %3d \n", x, sum, exp(-x), n);
  30. }
  31. printf ("------------------------------------------------\n");
  32. system("pause");
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement