Created
February 19, 2011 18:51
-
-
Save resure/835270 to your computer and use it in GitHub Desktop.
Лаба для Саркиса
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <locale.h> | |
#define N 4 | |
int main () { | |
setlocale(0, "russian"); | |
int a[N][N], i, j, buf, min, imin; | |
// Чтение матрицы | |
for (i = 0; i < 4; i++) { | |
for (j = 0; j < 4; j++) | |
scanf("%d", &a[i][j]); | |
} | |
printf("\n"); | |
for (i = 0; i < N; i++) { | |
for (j = 0; j < N; j++) { | |
if (j == 0) { | |
min = a[i][0]; | |
imin = 0; | |
} else { | |
if (a[i][j] < min) { | |
imin = j; | |
min = a[i][j]; | |
} | |
} | |
} | |
buf = a[i][imin]; | |
a[i][imin] = a[i][0]; | |
a[i][0] = buf; | |
} | |
for (i = 0; i < N; i++) { | |
for (j = 0; j < N; j++) | |
printf("%d ", a[i][j]); | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment