Advertisement
evgenko

Untitled

Jan 9th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <limits.h>
  4.  
  5. int main()
  6. {
  7.     int min_element = INT_MAX;
  8.     int min_row_index;
  9.     int min_col_index;
  10.     int rows,cols;
  11.     printf("Enter the count of rows: " );
  12.     scanf("%d",&rows);
  13.     printf("Enter the count of columns: ");
  14.     scanf("%d",&cols);
  15.     int array[rows][cols];
  16.     for (int i=0;i<rows;i++){
  17.         for (int j=0;j<cols;j++){
  18.             printf("Enter the element row(%d) column(%d) : ",i+1,j+1);
  19.             scanf("%d", &array[i][j]);
  20.             if (min_element>array[i][j]){
  21.                 min_element = array[i][j];
  22.                 min_row_index = i;
  23.                 min_col_index = j;
  24.             }
  25.         }
  26.     }
  27.     printf("------------------------\n");
  28.     printf("You are entered: \n");
  29.    for (int i=0;i<rows;i++){
  30.         for (int j=0;j<cols;j++){
  31.             printf("%d ", array[i][j]);
  32.         }
  33.         printf("\n");
  34.     }
  35.     array[min_row_index][min_col_index] = array[rows-1][0];
  36.     for (int i=0;i<cols;i++){
  37.         array[rows-1][i] = min_element;
  38.     }
  39.     printf("------------------------\n");
  40.     for (int i=0;i<rows;i++){
  41.         for (int j=0;j<cols;j++){
  42.             printf("%d ", array[i][j]);
  43.         }
  44.         printf("\n");
  45.     }
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement