- #1
ineedhelpnow
- 651
- 0
going through problems to study for a test
Resize vector countDown to have newSize elements. Populate the vector with integers newSize down to 1. Ex: If newSize = 3, then countDown = {3, 2, 1}, and the sample program outputs:
3 2 1 Go!
Sample program:
i tried countDown.resize(newSize); but it didnt work.
Resize vector countDown to have newSize elements. Populate the vector with integers newSize down to 1. Ex: If newSize = 3, then countDown = {3, 2, 1}, and the sample program outputs:
3 2 1 Go!
Sample program:
Code:
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> countDown(0);
int newSize = 0;
int i = 0;
newSize = 3;
<STUDENT CODE>
for (i = 0; i < newSize; ++i) {
cout << countDown.at(i) << " ";
}
cout << "Go!" << endl;
return 0;
}
i tried countDown.resize(newSize); but it didnt work.