1
0
Fork 0

Added Lab16

This commit is contained in:
Profitroll 2023-03-11 13:56:10 +01:00
parent a941edf78c
commit 16d9042f82
1 changed files with 52 additions and 1 deletions

View File

@ -1 +1,52 @@
???
#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;
}