Respuesta :
#include <iostream>
#include <vector>
#define NUM_GUESSES 3
int main()
{
std::vector<int> userGuesses;
for (int i = 0, input; i < NUM_GUESSES; i++)
{
std::cin >> input;
userGuesses.push_back(input);
}
}
#include <vector>
#define NUM_GUESSES 3
int main()
{
std::vector<int> userGuesses;
for (int i = 0, input; i < NUM_GUESSES; i++)
{
std::cin >> input;
userGuesses.push_back(input);
}
}
Answer:
The solution code is written in C++.
- vector<int> userGuesses;
- int NUM_GUESSES = 3;
- int i;
- int inputNum;
- for(i = 1; i <= NUM_GUESSES; i++){
- cin>>inputNum;
- userGuesses.push_back(inputNum);
- }
Explanation:
By presuming there is a vector, userGuesses and the NUM_GUESSES is 3 (Line 1 - 2).
Next we can create a for-loop that will run for NUM_GUESSES round of iterations. In each iteration, we use cin to get an input number and then use push_back method to add the input number to the userGuesses vector (Line 7 - 10).