Skip to content

Commit

Permalink
Merge pull request #1193 from Noodulz/patch-1
Browse files Browse the repository at this point in the history
Create addZeroToFirstIndex.cpp
  • Loading branch information
fineanmol committed Oct 25, 2021
2 parents a709158 + fb64899 commit 5e889fe
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include <vector>
using namespace std;

void shift(vector<int>& array);

int main() {
vector<int> arr = {1,0,4,3};
shift(arr);
for (int j = 0; j < arr.size(); j++) {
cout << arr[j] << " ";
}
cout << endl;
}
void shift(vector<int>& array) {
for (int i = array.size() - 2; i >= 1; i--) {
array[i+1] = array[i];
}
array[1] = 0;
}

0 comments on commit 5e889fe

Please sign in to comment.