Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- int x[2][4] = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } };
- int y[2][4] = { { 9, 10, 11, 12 }, { 13, 14, 15, 16 } };
- int a[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
- cout << "Printing the entire array: \n";
- for (int t = 0; t <16; t++){
- cout << " " << a[t];
- }
- cout << "\nPrinting per row: \n";
- for (int r = 0; r < 2; r++){
- for (int c = 0; c < 4; c++){
- cout << " " << x[r][c] << "";
- }
- cout << endl;
- }
- for (int r2 = 0; r2 < 2; r2++){
- for (int c2 = 0; c2 < 4; c2++){
- cout << " " << y[r2][c2] << "";
- }
- cout << endl;
- }
- int q[2][4] = { { 1, 5, 9, 13 }, { 2, 6, 10, 14 } };
- int w[2][4] = { { 3, 7, 11, 15 }, { 4, 8, 12, 16 } };
- cout << "Printing per column: \n";
- for (int r = 0; r < 2; r++){
- for (int c = 0; c < 4; c++){
- cout << " " << q[r][c] << "";
- }
- cout << endl;
- }
- for (int r2 = 0; r2 < 2; r2++){
- for (int c2 = 0; c2 < 4; c2++){
- cout << " " << w[r2][c2] << "";
- }
- cout << endl;
- }
- int e[2][4] = { { 1, 6, 11, 16 }, { 4, 7, 10, 13 } };
- cout << "Printing in diagonal form:" << endl;
- for (int r = 0; r < 2; r++){
- for (int c = 0; c < 4; c++){
- cout << " " << e[r][c] << "";
- }
- cout << endl;
- }
- system("pause>0");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement