Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Benchmark.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- //#include <cstdio.h>
- const int MAX_LEVEL = 4;
- const int PARTITION = 60;
- const double STEP = (1.0 / PARTITION);
- double euler(double val0, int level) {
- // cout << val0 << endl;
- double cur_val = val0;
- if (level == MAX_LEVEL) {
- for (int i = 0; i < PARTITION; ++i) {
- cur_val += (cur_val - cur_val * cur_val) * STEP;
- }
- }
- else
- for (int i = 0; i < PARTITION; ++i) {
- cur_val += fmod(euler(cur_val, level + 1), 10) * STEP;
- }
- return cur_val;
- }
- int main()
- {
- double x = 2.;
- cin >> x;
- for (int i = 0; i < 100; ++i){
- clock_t t1 = clock();
- double res = euler(x, 0);
- cout << (clock() - t1) << ' ' << res << endl;
- }
- int a;
- cin >> a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment