Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <limits.h>
- int main()
- {
- int min_element = INT_MAX;
- int min_row_index;
- int min_col_index;
- int rows,cols;
- printf("Enter the count of rows: " );
- scanf("%d",&rows);
- printf("Enter the count of columns: ");
- scanf("%d",&cols);
- int array[rows][cols];
- for (int i=0;i<rows;i++){
- for (int j=0;j<cols;j++){
- printf("Enter the element row(%d) column(%d) : ",i+1,j+1);
- scanf("%d", &array[i][j]);
- if (min_element>array[i][j]){
- min_element = array[i][j];
- min_row_index = i;
- min_col_index = j;
- }
- }
- }
- printf("------------------------\n");
- printf("You are entered: \n");
- for (int i=0;i<rows;i++){
- for (int j=0;j<cols;j++){
- printf("%d ", array[i][j]);
- }
- printf("\n");
- }
- array[min_row_index][min_col_index] = array[rows-1][0];
- for (int i=0;i<cols;i++){
- array[rows-1][i] = min_element;
- }
- printf("------------------------\n");
- for (int i=0;i<rows;i++){
- for (int j=0;j<cols;j++){
- printf("%d ", array[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement