Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void shiftTab(int tab[], int tabSize, int pos)
- {
- int teb[5];
- int counter = 0;
- int counterB = 0;
- for (int i = pos; i < tabSize; i++)
- {
- teb[counter] = tab[i];
- counter++;
- }
- if (counter != tabSize)
- {
- counterB = counter;
- for (int i = 0; i < tabSize - counter; i++)
- {
- teb[counterB] = tab[i];
- counterB++;
- }
- }
- for (int i = 0; i < 5; i++)
- {
- tab[i] = teb[i];
- }
- }
- int main()
- {
- int tab[] = { 1,2,3,4,5 };
- size_t theSize= sizeof(tab) / sizeof(tab[0]);
- shiftTab(tab, theSize, 1);
- for (size_t i = 0; i < theSize; i++)
- {
- cout << tab[i] << ' ';
- }
- cout << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement