Объяснение:
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand(time(NULL));
int m, n;
cin >> m >> n;
if (m <= 0 || n <= 0) return 0;
int** arr = new int* [m];
for (int i = 0; i < m; i++)
arr[i] = new int[n];
}
cout << endl;
for (int j = 0; j < n; j++)
arr[i][j] = rand() % 11 - 5;
cout.width(3);
cout << arr[i][j];
int belowZero = 0;
int sum = 0;
sum += arr[i][j];
if (sum < 0) belowZero++;
cout << " Answer: " << belowZero << endl;
delete[] arr[i];
delete[] arr;
Объяснение:
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand(time(NULL));
int m, n;
cin >> m >> n;
if (m <= 0 || n <= 0) return 0;
int** arr = new int* [m];
for (int i = 0; i < m; i++)
{
arr[i] = new int[n];
}
cout << endl;
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
arr[i][j] = rand() % 11 - 5;
cout.width(3);
cout << arr[i][j];
}
cout << endl;
}
cout << endl;
int belowZero = 0;
for (int i = 0; i < m; i++)
{
int sum = 0;
for (int j = 0; j < n; j++)
{
sum += arr[i][j];
}
if (sum < 0) belowZero++;
}
cout << " Answer: " << belowZero << endl;
for (int i = 0; i < m; i++)
{
delete[] arr[i];
}
delete[] arr;
}