- #1
ineedhelpnow
- 651
- 0
Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 30, 40}, then newScores = {20, 30, 40, 10}.
Sample program:
(Worried) I've been staring at this problem for a while. how do i do it? i need to use a for loop i believe (i=0;i<SCORES_SIZE;++i). i don't know what to put in the loop.
Sample program:
Code:
#include <iostream>
#include <vector>
using namespace std;
int main() {
const int SCORES_SIZE = 4;
vector<int> oldScores(SCORES_SIZE);
vector<int> newScores(SCORES_SIZE);
int i = 0;
oldScores.at(0) = 10;
oldScores.at(1) = 20;
oldScores.at(2) = 30;
oldScores.at(3) = 40;
<STUDENT CODE>
for (i = 0; i < SCORES_SIZE; ++i) {
cout << newScores.at(i) << " ";
}
cout << endl;
return 0;
}
(Worried) I've been staring at this problem for a while. how do i do it? i need to use a for loop i believe (i=0;i<SCORES_SIZE;++i). i don't know what to put in the loop.