From 16d9042f82edb5adb8b3381d7a52c8487d592a1a Mon Sep 17 00:00:00 2001 From: Profitroll <47523801+profitrollgame@users.noreply.github.com> Date: Sat, 11 Mar 2023 13:56:10 +0100 Subject: [PATCH] Added Lab16 --- 16/Lab16/Lab16.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/16/Lab16/Lab16.cpp b/16/Lab16/Lab16.cpp index 66c441f..60ecabf 100644 --- a/16/Lab16/Lab16.cpp +++ b/16/Lab16/Lab16.cpp @@ -1 +1,52 @@ -??? \ No newline at end of file +#include +#include +#include + +using namespace std; + +int main() { + + SetConsoleOutputCP(CP_UTF8); + + const int ROWS = 4; + const int COLS = 9; + double input_matrix[ROWS][COLS]; + + // Отримати дані для матриці 4x9 + cout << "Введіть елементи матриці 4x9: " << endl; + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + cin >> input_matrix[i][j]; + } + } + + // Створити нову матрицю + vector> new_matrix; + for (int j = 0; j < COLS; j++) { + bool has_element_gt_100 = false; + for (int i = 0; i < ROWS; i++) { + if (input_matrix[i][j] > 100) { + has_element_gt_100 = true; + break; + } + } + if (has_element_gt_100) { + vector new_col; + for (int i = 0; i < ROWS; i++) { + new_col.push_back(input_matrix[i][j]); + } + new_matrix.push_back(new_col); + } + } + + // Вивести нову матрицю + cout << "Нова матриця: " << endl; + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < new_matrix.size(); j++) { + cout << new_matrix[j][i] << " "; + } + cout << endl; + } + + return 0; +} \ No newline at end of file