It is necessary to calculate the amount of elements of each line of the matrix V (4.5) or the amount
Positive elements of the columns of this matrix at the instructions of the user.
There is a code that creates a matrix of the specified bearer and displays it (but for some reason only from positive numbers). But I do not know how to count the items and how to do it by selecting a user. If it is not difficult for you, I will be very grateful for your help.
# include & lt; iostream & gt;
# INCLUDE & LT; CTIME & GT;
Using Namespace STD;
INT MAIN ()
{
SETLOCALE (0, "");
SRAND (Unsigned (Time (NULL));
int n, m;
COUT & LT; & LT; "Enter the size of the matrix:";
CIN & GT; & GT; N & gt; & gt; M;
int ** a = new int * [n];
for (int i = 0; i & lt; n; i ++)
A [i] = new int [M];
for (int i = 0; i & lt; n; i ++)
for (int j = 0; j & lt; m; j ++)
A [i] [j] = ((rand ()% 20));
COUT & LT; & LT; "Your Matrix:" & LT; & LT; Endl & lt; & lt; Endl;
for (int i = 0; i & lt; n; i ++)
{
for (int j = 0; j & lt; m; j ++)
COUT & LT; & LT; A [i] [j] & lt; & lt; "";
COUT & LT; & LT; Endl;
}
COUT & LT; & LT; Endl;
for (int i = 0; i & lt; n; i ++)
delete [] a [i];
delete [] a;
}
Answer 1
Positive numbers, these are numbers that are more “0”, add a condition to this code code:
if (a [i] [j] & gt; 0)
{
SUM + = 1;
}
So in the SUM variable you will receive the number of positive elements