-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfibonacci.cpp
More file actions
51 lines (44 loc) · 960 Bytes
/
Copy pathfibonacci.cpp
File metadata and controls
51 lines (44 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;
typedef vector <int> V;
V fibo(int n)
{
V x={};
int num, i;
cout << n << endl;
for (i = 0; i < 3; i++)
cout << i << endl;
if (i == 0)
{
cout << "i==0: " << endl;
x.push_back(0);
cout << x[0] << endl;
}
if (i == 1)
{
cout << "i==1: " << endl;
x.push_back(1);
cout << x[1] << endl;
}
if (i > 1)
{
cout << "i>1: " << endl;
num = x[i-2]+x[i-1];
cout << num << endl;
x.push_back(num);
}
return x;
}
int main()
{
auto m = fibo(4);
cout << "results:" << endl;
cout << m[5] << endl;
//x.push_back(5);
cout << typeid(m[4]).name() << endl;
//cout << x << endl;
return 0;
}