It works
The code I used was:
Code:
int main()
{
vector<int> VECTOR;
VECTOR.push_back(1);
VECTOR.push_back(1);
VECTOR.push_back(2);
VECTOR.push_back(6);
VECTOR.push_back(24);
cout << VECTOR[4] << endl;
}
Which outputted 24.
I have another question that is related to all of this.
In Python, a user can input a list, such as:
Code:
LIST = input("Input your list here: ")
LIST.append(1)
print LIST
What this does is ask the user to input a list called LIST.
Afterward, LIST has the number 1 appended to it.
If the user writes [0,1,2,3,4,5] as their input LIST, the
script outputs [0,1,2,3,4,5,1]
Would the C++ equivalent look something like this?
Code:
int main()
{
// VECTOR defined here
vector<int> VECTOR;
// User inputs into VECTOR
std::cin>>VECTOR;
// Adds "1" into VECTOR
VECTOR.push_back(1);
// couts from 0 to Vector size
for (i==0;i<(VECTOR.size());i++)
{
cout << VECTOR[i] << endl;
}
}
Thanks for all your help