Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void Rotate(int *table, int *secondArray);
- int N, Size, placeValue, counter = 0;
- int main()
- {
- cout << "Enter a size for the array to rotate" << endl;
- cin >> Size;
- N = Size*Size;
- placeValue = N - Size;
- int toRotate[N];
- int Rotated[N];
- for(int i = 0; i < N; i++)
- {
- int currentValue;
- cout << "Pick a random digit between 0 and 9" << endl;
- cin >> currentValue;
- toRotate[i] = currentValue;
- }
- for(int i = 0; i < N; i++)
- {
- cout << toRotate[i];
- }
- cout << endl;
- Rotate(toRotate, Rotated);
- cout << endl;
- for(int i = 0; i < N; i++)
- {
- cout << Rotated[i];
- }
- return 0;
- }
- void Rotate(int *table, int *secondArray)
- {
- for(int i = 0; i < Size; i++)
- {
- for(int c = 0; c < Size; c++)
- {
- cout << *(table + placeValue);
- secondArray[counter] = *(table + placeValue);
- placeValue = placeValue - Size;
- counter++;
- }
- placeValue = i;
- placeValue = placeValue + (N - Size) + 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement