Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- const int rows = 3;
- const int cols = 4;
- int temp[4] = { 0 };
- int matrix[rows][cols] = {
- {1, 2, 3, 4},
- {5, 6, 7, 8},
- {9, 10, 11, 12}
- };
- // temp = row0 , row0=row1, row1 = temp
- for (int i = 0; i < cols; i++)
- {
- temp[i] = matrix[0][i];
- }
- for (int i = 0; i < cols; i++)
- {
- matrix[0][i] = matrix[1][i];
- }
- for (int i = 0; i < cols; i++)
- {
- matrix[1][i] = temp[i];
- }
- for (int r = 0; r < rows; r++)
- {
- for (int c = 0; c < cols; c++)
- {
- cout << " "<<matrix[r][c] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement