Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int array[4][4] {{ 96, 26, 31, 81 },
- { 41, 71, 66, 56 },
- { 61, 51, 46, 76 },
- { 36, 86, 91, 21 }
- };
- int flippedArray[4][4] {{ 0, 26, 31, 0 },
- { 41, 0, 0, 56 },
- { 61, 0, 0, 76 },
- { 0, 86, 91, 0 }
- };
- void printArray()
- {
- for(int row = 0; row < 4; row++)
- {
- for (int col = 0; col < 4; col++)
- {
- cout << array[row][col] << "\t";
- }
- cout << endl;
- }
- cout << endl;
- }
- void printFlippedArray()
- {
- for(int row = 0; row < 4; row++)
- {
- for (int col = 0; col < 4; col++)
- {
- cout << flippedArray[row][col] << "\t";
- }
- cout << endl;
- }
- cout << endl;
- }
- void reverseLeft()
- {
- int newRow= 3;
- int newCol = 3;
- int counter = 0;
- for(int row = 0; row < 4; row++)
- {
- for (int col = 0; col < 1; col++)
- {
- flippedArray[newRow][newCol] = array[row][counter];
- }
- counter++;
- newRow--;
- newCol--;
- }
- }
- void reverseRight()
- {
- int newRow= 3;
- int newCol = 0;
- int counter = 3;
- for(int row = 0; row < 4; row++)
- {
- for (int col = 0; col < 1; col++)
- {
- flippedArray[newRow][newCol] = array[row][counter];
- }
- counter--;
- newRow--;
- newCol++;
- }
- }
- int main()
- {
- printArray();
- reverseLeft();
- reverseRight();
- cout << endl;
- printFlippedArray();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement