Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using std::cout;
- #define SIZE 5
- void ShiftArrayValues(int *pArray);
- void PrintArrayValues(int *pArray);
- int main()
- {
- int *pArray = new int[SIZE];
- for (int i = 0; i < SIZE; ++i)
- {
- *(pArray + i) = rand() % 10;
- cout << i << " = " << *(pArray + i) << "\n";
- }
- for (int i = 0; i < 5; ++i)
- {
- cout << "\n \n";
- ShiftArrayValues(pArray);
- PrintArrayValues(pArray);
- }
- delete[] pArray;
- return 0;
- }
- void ShiftArrayValues(int *pArray)
- {
- cout << "ShiftArrayValues:\n";
- int iBuffer = *pArray;
- for (int i = 0; i < SIZE-1; ++i)
- {
- *(pArray + i) = *(pArray + i + 1);
- }
- *(pArray + 4) = iBuffer;
- }
- void PrintArrayValues(int *pArray)
- {
- for (int i = 0; i < SIZE; ++i)
- {
- cout << i << " == " << *(pArray + i) << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement