52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
#include <windows.h>
|
|
|
|
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<vector<double>> 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<double> 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;
|
|
} |