Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int m, n;
- scanf("%d %d", &m, &n);
- int arr[m][n];
- // input
- for (int row = 0; row < m; row++) {
- for (int col = 0; col < n; col++) {
- scanf("%d", &arr[row][col]);
- }
- }
- printf("\n");
- // Row-wise
- printf("Row-wise: ");
- for (int row = 0; row < m; row++) {
- for (int col = 0; col < n; col++) {
- printf("%d ", arr[row][col]);
- }
- }
- printf("\n");
- // Column-wise
- printf("Column-wise: ");
- for (int row = 0; row < n; row++) {
- for (int col = 0; col < m; col++) {
- printf("%d ", arr[col][row]);
- }
- }
- printf("\n");
- }
- // int main() {
- // int n, m;
- // printf("Enter row and column:\n");
- // scanf("%d %d", &n, &m);
- // int arr[n][m];
- // // Print
- // // printf("%d %d %d\n", arr[0][0], arr[0][1], arr[0][2]);
- // // input
- // for (int row = 0; row < n; row++) {
- // for (int col = 0; col < m; col++) {
- // scanf("%d", &arr[row][col]);
- // }
- // }
- // printf("\n");
- // // Output
- // for (int row = 0; row < n; row++) { // -> outer loop
- // for (int col = 0; col < m; col++) { // -> inner loop
- // printf("%d ", arr[row][col]);
- // }
- // printf("\n");
- // }
- // printf("\n");
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement