Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define MAX_SIZE_ROW 100
  4. #define MAX_SIZE_COLUMN MAX_SIZE_ROW * 4
  5.  
  6. void input(int matrix[][MAX_SIZE_COLUMN], int rowCount, int columntCount) {
  7.     printf("Input matrix elements\n");
  8.     for (int i = 0; i < rowCount; i++) {
  9.         for (int j = 0; j < columntCount; j++) {
  10.             printf("Element [%d][%d]:", i, j);
  11.             scanf("%d", &matrix[i][j]);
  12.             printf("\n");
  13.         }
  14.         printf("\n");
  15.     }
  16. }
  17.  
  18. void printMatrix(int matrix[][MAX_SIZE_COLUMN], int rowCount, int columntCount) {
  19.     for (int i = 0; i < rowCount; i++) {
  20.         for (int j = 0; j < columntCount; j++) {
  21.             printf("[%d][%d]=%d ", i, j, matrix[i][j]);
  22.         }
  23.  
  24.         printf("\n");
  25.     }
  26. }
  27.  
  28. int main()
  29. {
  30.     int matrix[MAX_SIZE_ROW][MAX_SIZE_COLUMN];
  31.     int rowCount;
  32.     int columnCount;
  33.  
  34.     printf("Enter number of rows\n");
  35.     scanf("%d", &rowCount);
  36.     columnCount = rowCount * 4;
  37.     printf("Number of rows: %d, number of columns: %d\n", rowCount, columnCount);
  38.  
  39.     //Task 3 - Input data
  40.     input(matrix, rowCount, columnCount);
  41.  
  42.     //Task 4 - Print the input data
  43.     printMatrix(matrix, rowCount, columnCount);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement