Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <cmath>
- #include<ctime>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- srand((unsigned)time(NULL));
- int l, r, s = 0;
- cout << "Введите кол-во линий = ";
- cin >> l;
- cout << "Введите кол-во столбцов = ";
- cin >> r;
- if (l > 20 || r > 20 || r < 1 || l < 1)
- {
- return 1;
- }
- int** arr;
- arr = new int* [l];
- for (int i = 0; i < l; i++)
- arr[i] = new int[r];
- cout << "Введите " << l * r << " элементов матрицы: ";
- for (int i = 0; i < l; i++)
- {
- for (int j = 0; j < r; j++)
- {
- cin >> arr[i][j];
- }
- }
- cout << "Элементы массива: " << endl;
- for (int i = 0; i < l; i++)
- {
- for (int j = 0; j < r; j++)
- {
- cout << arr[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl << endl << endl;
- for (int i = 0; i < l; i++)
- {
- for (int j = 0; j < r; j++)
- {
- if (arr[i][j] == 0)
- s++;
- }
- if (s == 1)
- {
- cout << endl << i + 1 << "-ая " << "строка содержит единственный нуль" << endl;
- s = 0;
- }
- else
- cout << i + 1 << "-ая " << "строка содержит больше 1 нуля, либо не содержит их вовсе!" << endl;
- }
- cout << endl << endl << endl;
- for (int i = 0; i < l; i++)
- {
- for (int j = 0; j < r; j++)
- {
- if (arr[j][i] == 0)
- s++;
- }
- if (s == 1)
- {
- cout << endl << i + 1 << "-й " << "столбец содержит единственный нуль" << endl;
- s = 0;
- }
- else
- cout << i + 1 << "-й " << "столбец содержит больше 1 нуля, либо не содержит их вовсе!" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement