Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <ctime>
- #include <cmath>
- const int N = 20, D = 46;
- int method1(int k) {
- int a = 0, b = 1;
- for (int i = 0; i < k; ++i) {
- b = a + b;
- a = b - a;
- }
- return a;
- }
- int main()
- {
- clock_t start;
- double duration;
- int RandFib[N];
- int Fib1[N], Fib2[N], Fib3_2[N], Fib4[N];
- float Fib3_1[N];
- srand(time(NULL));
- for (int i = 0; i < N; ++i) {
- if (i % 5 == 0) cout << endl;
- RandFib[i] = rand() % (D + 1);
- cout << RandFib[i] << "\t";
- }
- cout << endl;
- cout << endl;
- start = clock();
- for (int i = 0; i < N; ++i) {
- Fib1[i] = method1(RandFib[i]);
- }
- duration = (clock() - start) / (double)CLOCKS_PER_SEC;
- cout << "Duration: " << duration << endl << endl;
- for (int i = 0; i < N; ++i) {
- cout << Fib1[i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement