С++. определить максимальный элемент матрицы на главной диагонали и сумму элементов этой диагонали. размер матрицы вводить с клавиатуры, элементы, а также результат, разместить в памяти динамически.
167
382
Ответы на вопрос:
#include < iostream> #include < cstdlib> using namespace std; int main(){ int *enter = new int; cout < < "enter x: "; cin > > *enter; const int *x = new int(*enter); *enter = 0; cout < < "enter y: "; cin > > *enter; const int *y = new int(*enter); int *mat = new int[*x][*y]; for (int i = 0; i < *x; i++){ for (int j = 0; j < *y; j++){ cout < < "enter [" < < i < < "][" < < j < < "]: "; cin > > mat[i][j]; }; }; int *max = new int(0); for (int i = 0; i < *x; i++){ if (mat[*x] > *max){ *max = mat[*x]; }; }; }
Популярно: Информатика
-
Rokwe17.12.2021 03:32
-
384839010.05.2020 11:38
-
эги101.04.2020 04:26
-
ok68300011.09.2020 20:02
-
serhio200012.08.2021 15:19
-
phon111.06.2020 14:00
-
garcinia27.10.2022 10:05
-
ekzz125.03.2022 00:31
-
hehehdhd28.09.2020 21:53
-
SashylikS01.06.2022 09:45