Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://vk.com/evgenykravchenko0
- ___ ___ ___
- / /\ ___ / /\ / /\
- / /:/_ /__/\ / /:/_ / /:/_
- / /:/ /\ \ \:\ / /:/ /\ / /:/ /\
- / /:/ /:/_ \ \:\ / /:/_/::\ / /:/ /:/_
- /__/:/ /:/ /\ ___ \__\:\ /__/:/__\/\:\ /__/:/ /:/ /\
- \ \:\/:/ /:/ /__/\ | |:| \ \:\ /~~/:/ \ \:\/:/ /:/
- \ \::/ /:/ \ \:\| |:| \ \:\ /:/ \ \::/ /:/
- \ \:\/:/ \ \:\__|:| \ \:\/:/ \ \:\/:/
- \ \::/ \__\::::/ \ \::/ \ \::/
- \__\/ ~~~~ \__\/ \__\/
- ___
- /__/\ ___ ___
- \ \:\ / /\ / /\
- \ \:\ / /:/ / /:/
- _____\__\:\ /__/::\ /__/::\
- /__/::::::::\ \__\/\:\__ \__\/\:\__
- \ \:\~~\~~\/ \ \:\/\ \ \:\/\
- \ \:\ ~~~ \__\::/ \__\::/
- \ \:\ /__/:/ /__/:/
- \ \:\ \__\/ \__\/
- \__\/
- int modulo(int a)
- {
- if (a >= 0)
- {
- return a;
- }
- else
- {
- return -a;
- }
- }
- #include <stdio.h>
- int main()
- {
- int i = 0;
- int j = 0;
- int sum = 0;
- int max = 0;
- int N = 0;
- printf("Введите значение N для матрицы N*N\n");
- scanf("%d", &N);
- int matrix[N][N];
- printf("Введите матрицу\n"); // создание матрицы
- for (i = 0; i < N; i++)
- {
- for (j = 0; j < N; j++)
- {
- scanf("%d", &matrix[i][j]);
- }
- }
- for (i = 0; i < N; i++) //работа с матрицей
- {
- for (j = 0; j < N; j++)
- {
- if (matrix[i][j] % 2 != 0)
- {
- sum += modulo(matrix[i][j]);
- }
- else
- {
- sum = 0;
- j =0;
- break;
- }
- }
- if (sum > max)
- {
- max = sum;
- sum = 0;
- }
- sum = 0;
- }
- printf("Максимум = %d\n", max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement