
Patrick B. answered 10/28/20
Math and computer tutor/teacher
- Compiler error: extra closing curly brace in the middle of main()
- not prompting for input
- declare an empty vector to start; then insert each number using iterator.end();
- you can use the overloaded operator [] to index the array
Here's the code:
using namespace std;
int main()
{
const int NUM_GUESSES = 3;
vector<int> userGuesses(0);
unsigned int i;
for (i = 0; i < NUM_GUESSES; ++i)
{
int iNum;
cout << " Please input the # :>";
cin >> iNum;
vector<int>::iterator iIndexPos = userGuesses.end();
userGuesses.insert(iIndexPos,iNum);
}
int N = userGuesses.size();
for (i=0; i<N; i++)
{
cout <<userGuesses[i] << endl;
}
return 0;
}