Last active
January 7, 2019 17:52
-
-
Save daniilgri/ee965d4d0758f39a1b7440e909913824 to your computer and use it in GitHub Desktop.
This file contains 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 "pch.h" | |
#include <iostream> | |
#include <stdlib.h> | |
#include <conio.h> | |
#include <windows.h> | |
int main() | |
{ | |
SetConsoleOutputCP(1251); | |
SetConsoleCP(1251); | |
int n, m; | |
int i, j; | |
printf("Введите n и m: "); | |
scanf_s("%i%i", &n, &m); | |
printf("\n"); | |
int matrix[10][10]; | |
for (i = 0; i < n; i++) { | |
for (j = 0; j < m; j++) { | |
printf("Введите matrix[%i][%i]: ", i+1, j+1); | |
scanf_s("%i", *(matrix + i) + j); | |
} | |
printf("\n"); | |
} | |
int min; | |
for (j = 0; j < 1; j++) { | |
min = matrix[0][j]; | |
for (i = 1; i < n; i++) { | |
if (min > matrix[i][j]) { | |
min = matrix[i][j]; | |
printf("Min: %i", min); | |
} | |
} | |
} | |
int temp; | |
for (j = 1; j < m; j++) { | |
min = nextMin; | |
nextMin = matrix[0][j]; | |
for (i = 1; i < n; i++) { | |
if (nextMin > matrix[i][j]) { | |
nextMin = matrix[i][j]; | |
printf("NextMin: %i\n", nextMin); | |
} | |
} | |
if (nextMin < min) { | |
for (i = 0; i < n; i++) { | |
temp = matrix[i][j]; | |
matrix[i][j] = matrix[i][j - 1]; | |
matrix[i][j - 1] = temp; | |
} | |
} | |
} | |
for (i = 0; i < n; i++) { | |
for (int j = 0; j < m; j++) { | |
printf(" matrix[%i][%i] = %i ", i+1, j+1, matrix[i][j]); | |
} | |
printf("\n"); | |
} | |
_getch(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment