#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>

using namespace std;

bool find(int m, int n, int ** mas) {
	for (int i = 0; i<m; i++) {
		for (int j = 0; j<n; j++) {
			if (mas[i][j]<0) return true;
		}
	}
	return false;
}

int main() {
	int a;
	srand(time(0));
	cout << "Введите размер матрицы MxN" << endl << "M=";
	cin >> a;
	int m = a;
	cout << endl << "N=";
	cin >> a;
	int n = a;
	cout << endl << "Сгенерируем матрицу и проверим, встречаются ли среди её эллементов отрицательные" << endl;
	int **mas = new int*[m];
	for (int i = 0; i<m; i++)
	{
		mas[i] = new int[n];
		for (int j = 0; j<n; j++)
		{
			mas[i][j] = rand() % 20 - 10;
			cout << mas[i][j] << " ";
		}
		cout << endl;
	}
	if (find(m, n, mas) == true) cout << "В данной матрице встречаются отрицательные элементы.";
	else cout << "В данной матрице не встречаются отрицательные элементы.";

	for (int i = 0; i < m; i++)
	{
		delete[] mas[i];
	}
	delete[] mas;
	return 0;
}