Guest User

Untitled

a guest
Jan 28th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. // Benchmark.cpp: определяет точку входа для консольного приложения.
  2. //
  3. #include "stdafx.h"
  4. //#include <cstdio.h>
  5.  
  6. const int MAX_LEVEL = 4;
  7. const int PARTITION = 60;
  8. const double STEP = (1.0 / PARTITION);
  9. double euler(double val0, int level) {
  10. // cout << val0 << endl;
  11. double cur_val = val0;
  12. if (level == MAX_LEVEL) {
  13. for (int i = 0; i < PARTITION; ++i) {
  14. cur_val += (cur_val - cur_val * cur_val) * STEP;
  15. }
  16. }
  17. else
  18. for (int i = 0; i < PARTITION; ++i) {
  19. cur_val += fmod(euler(cur_val, level + 1), 10) * STEP;
  20. }
  21. return cur_val;
  22. }
  23.  
  24. int main()
  25. {
  26. double x = 2.;
  27. cin >> x;
  28. for (int i = 0; i < 100; ++i){
  29. clock_t t1 = clock();
  30. double res = euler(x, 0);
  31. cout << (clock() - t1) << ' ' << res << endl;
  32. }
  33. int a;
  34. cin >> a;
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment