I am attempting to take a value N, and create a list/vector with all of the values from N to 0 (not inclusive), and then N again.
After defining N, I have the following code:
for (int i = N; i > 0; i--) {
cout << i << endl;
}
This neatly prints out the required values. For example, with N=3:
3
2
1
3
The issue is that I can't manipulate these to compute what I want to (namely the mean, range, maximum and minimum values). So what I need to do is to get each iteration to put itself into an array, the same array that the previous iteration put itself in.
I have found a similar question on here (How to store the result of each iteration of a for loop into an array (Javascript)), except it's in javascript, which is causing some issues for me.
Why does the following not work on C++, and how can I change it?
var array = []
for (int i = N-1; i < N; i--) {
array.push(i);
}
The same thing with int replacint var does not work either.
Any suggestions?