#include <iostream>
#include <ctime>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
const int N = 5;
const int M = 5;
int a[N][M];
srand((unsigned)time(0));
cout << "Массив:\n";
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
{
a[i][j] = rand() % 21 - 10; // [-10;10]
cout << a[i][j] << "\t";
}
cout << endl;
}
bool found = false;
for (int i = 0; i < N; i++)
{
bool allNegative = true;
for (int j = 0; j < M; j++)
{
if (a[i][j] >= 0)
{
allNegative = false;
break;
}
}
if (allNegative)
{
cout << "\nСтрока " << i + 1
<< " состоит только из отрицательных элементов.\n";
found = true;
}
}
if (!found)
cout << "\nСтрок, состоящих только из отрицательных элементов, нет.\n";
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
const int N = 5;
const int M = 5;
int a[N][M];
int b[M];
srand((unsigned)time(0));
cout << "Исходный массив:\n";
for (int i = 0; i < N; i++)
{
for (int j = 0; j < M; j++)
{
a[i][j] = rand() % 21 - 10; // [-10;10]
cout << a[i][j] << "\t";
}
cout << endl;
}
for (int j = 0; j < M; j++)
{
b[j] = 0;
for (int i = 0; i < N; i++)
{
if (a[i][j] < 0)
{
b[j] = a[i][j];
break;
}
}
}
cout << "\nПолученный одномерный массив:\n";
for (int j = 0; j < M; j++)
cout << b[j] << " ";
cout << endl;
return 0;
}