Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main() {
- int N;
- printf("Введите порядок матрицы N: ");
- scanf("%d", &N);
- int matrix[N][N];
- srand(time(NULL));
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < N; j++) {
- matrix[i][j] = rand() % 100 + 1;
- }
- }
- printf("Сгенерированная матрица:\n");
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < N; j++) {
- printf("%3d ", matrix[i][j]);
- }
- printf("\n");
- }
- int min_value = matrix[0][0];
- for (int i = 0; i < N; i++) {
- if (matrix[i][i] < min_value) {
- min_value = matrix[i][i];
- }
- if (matrix[i][N - 1 - i] < min_value) {
- min_value = matrix[i][N - 1 - i];
- }
- }
- printf("Наименьшее значение на диагоналях: %d\n", min_value);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement