| 5 | int main(); |
| 6 | |
| 7 | void read_display() |
| 8 | { |
| 9 | system("cls"); |
| 10 | cout << "\t\tREAD AND DISPLAY\n"; |
| 11 | cout << "Please input information about 2D array: " << endl; |
| 12 | int row_input, col_input; |
| 13 | cout << "Rows (max 5): "; |
| 14 | cin >> row_input; |
| 15 | cout << "Columns (max 5): "; |
| 16 | cin >> col_input; |
| 17 | int a[5][5]; |
| 18 | cout << "Now input elements of Matrix: "; |
| 19 | if (row_input > 0 && row_input <= 5 && col_input > 0 && col_input <= 5) |
| 20 | { |
| 21 | for (int row = 0; row < row_input; row++) |
| 22 | { |
| 23 | for (int col = 0; col < col_input; col++) |
| 24 | { |
| 25 | cin >> a[row][col]; |
| 26 | } |
| 27 | } |
| 28 | cout << "Result: \n"; |
| 29 | for (int row = 0; row < row_input; row++) |
| 30 | { |
| 31 | for (int col = 0; col < col_input; col++) |
| 32 | { |
| 33 | |
| 34 | cout << a[row][col] << " "; |
| 35 | } |
| 36 | cout << endl; |
| 37 | } |
| 38 | cout << endl; |
| 39 | cout << "Do you want to try again? (Yes = 1, No = Any Key)\n"; |
| 40 | string respond; |
| 41 | cout << "Your choice: "; |
| 42 | cin >> respond; |
| 43 | if (respond == "1") |
| 44 | { |
| 45 | system("cls"); |
| 46 | read_display(); |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | system("cls"); |
| 51 | main(); |
| 52 | } |
| 53 | } |
| 54 | else |
| 55 | { |
| 56 | system("cls"); |
| 57 | cout << "Please input valid numbers from 1 to 5 ! " << endl; |
| 58 | read_display(); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | void transpose() |
| 63 | { |
no test coverage detected