aboutsummaryrefslogtreecommitdiff
path: root/Project1/helper.cpp
blob: c51a05eb54c2c24bbc812194b0a2c03c15a1ebf9 (plain) (blame)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "helper.h"
#include <iostream>
#include <array>
#include <vector>
#include <list>

using std::cin;
using std::cout;
using std::endl;
using std::array;
using std::vector;


void Print(int(&cArray)[SIZE])
{
	for(auto element: cArray)
	{
		std::cout << element << std::endl;
	}
}

void Print(const std::array<int, SIZE> &stdArray)
{
	for (auto i = 0u; i < stdArray.size(); i++)
	{
		std::cout << i << std::endl;
	}
}

void Print(const std::vector<int> &myVector)
{
	for (auto& i : myVector)
	{
		std::cout << i << std::endl;
	}

}

void Print(const std::list<int>& myList)
{
	for (auto& i : myList)
	{
		cout << i << endl;
	}

}

void Fibonacci(int(&cArray)[SIZE])
{
	int y = 0;
	cout << "enter the last element of the Fibonacci sequence you would like to see: ";
	cin >> y;
	cArray[0] = 0;
	cArray[1] = 1;
	for (int i = 2; i < y; i++)
	{
		cArray[i] = cArray[i - 1] + cArray[i - 2];
	}
	for (int i = 0; i < y; i++)
	{
		cout << cArray[i] << " ";
	}
}

void Fibonacci(std::array<int, SIZE>& stdArray)
{
	int y = 0;
	cout << "enter the last element of the Fibonacci sequence you would like to see: ";
	cin >> y;
	stdArray[0] = 0;
	stdArray[1] = 1;
	for (int i = 2; i < y; i++)
	{
		stdArray[i] = stdArray[i - 1] + stdArray[i - 2];
	}
	for (int i = 0; i < y; i++)
	{
		cout << stdArray[i] << " ";
	}
}

void Fibonacci(std::vector<int>& myVector)
{
	int y = 0;
	cout << "enter the last element of the Fibonacci sequence you would like to see: ";
	cin >> y;
	myVector[0] = 0;
	myVector[1] = 1;
	for (int i = 2; i < y; i++)
	{
		myVector[i] = myVector[i - 1] + myVector[i - 2];
	}
	for (int i = 0; i < y; i++)
	{
		cout << myVector[i] << " ";
	}
}

void Fibonacci(std::list<int>& myList)
{
	int y = 0;
	cout << "enter the last element of the Fibonacci sequence you would like to see: ";
	cin >> y;
	for (auto& i : myList)
	{
		i = (i - 1) + (i - 2);
		cout << i << " ";
	}
}