mihainan

Ex 7 - Lab03 PC

Oct 19th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6. freopen("lab-03-07.in", "r", stdin);
  7. freopen("lab-03-07.out", "w", stdout);
  8. int n, i;
  9. int t[10000];
  10. double x, EPS, s1, s2, s3, s4;
  11. scanf("%lf %d %lf", &x, &n, &EPS);
  12. t[0] = 1;
  13. s3 = 1;
  14. if(EPS>1)
  15. {
  16. s4 = 1;
  17. }
  18. else
  19. {
  20. s4 = 0;
  21. }
  22. for(i=1;i<=n;i++)
  23. {
  24. t[i] = t[i-1] * x/i;
  25. s3+=t[i];
  26. if(t[i]>EPS)
  27. s4+=t[i];
  28. }
  29. s1 = exp(x);
  30. s2 = pow(2.718, x);
  31. printf("%lf %lf %lf %lf\n", s3, s4, s1, s2);
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment