ссылка на задачу - https://studwork.ru/order/4462671-reshit-zadachu-s-matricami-s#file_2181281
тоже самое только ООП