Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "Russian");
- int rows=20;
- int cols=20;
- cout << "Введите количество строк: ";
- cin >> rows;
- cout << "Введите количество столбцов: ";
- cin >> cols;
- if (int(rows) <=0 || int(cols) <=0 )
- {
- cout << "Введены неверные значение" << endl;
- return 0;
- }
- if (int(rows) != int(cols)) {
- cout << "Не квадратная матрица" << endl;
- return 0;
- }
- int **arr = new int*[rows];
- for (int i = 0; i < rows; i++) {
- arr[i] = new int[cols];
- }
- for (int i = 0; i < rows; i++) {
- for (int j = 0; j < cols; j++) {
- cout << "строка # "<< i+1 << "\t";
- cout << "столбец # "<<j+1 << "= ";
- cin >> arr[i][j];
- }
- }
- for (int i = 0; i < rows; i++) {
- for (int j = 0; j < cols; j++) {
- cout << arr[i][j] << "\t";
- }
- cout << endl;
- }
- for (int i = 0; i < rows; ++i)
- {
- int max = 0;
- for (int j = 0; j < cols; ++j)
- {
- if ((arr[j][i] > arr[j + 1][i]) && (arr[j][i] > max));
- }
- cout << "В " << i + 1 << " столбце макс. элемент " << max << endl;
- }
- for (int i = 0; i < rows; i++)
- {
- delete[] arr[i];
- }
- delete[] arr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement