Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int n, m;
- char c;
- if (scanf("%d %d%c", &n, &m, &c) == 3 && c == '\n') {
- int **A = malloc(n * sizeof(int *));
- for (int i = 0; i < n; i++)
- A[i] = malloc(m * sizeof(int));
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++)
- if (scanf("%d%c", &A[i][j], &c) == 2 && (c == ' ' || c == '\n')) {
- } else {
- printf("n/a");
- break;
- }
- int min = A[0][0];
- int max = A[0][0];
- int str_min = 0;
- int str_max = 0;
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++) {
- if (A[i][j] < min) {
- min = A[i][j];
- str_min = i;
- }
- if (A[i][j] > max) {
- max = A[i][j];
- str_max = i;
- }
- }
- printf("%d %d %d %d\n", max, min, str_min, str_max);
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++)
- if (i == str_min)
- printf("%d ", A[str_max][j]);
- else if (i == str_max)
- printf("%d ", A[str_min][j]);
- else
- printf("%d ", A[i][j]);
- printf("\b\n");
- }
- printf("\b");
- } else {
- printf("n/a");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement