Язык указывать надо, а то не понятно Си или C++
/* программа на языке Си */
#include
#include
#include
int main()
{
int n,m,**a,*q,x,y;
do
{
printf("Kolichestvo strok = ");
scanf("%d", &n);
if(n < 1) printf("n > 0\n");
}while(n < 1);
do
{
printf("Kolichestvo stobcov = ");
scanf("%d", &m);
if(m < 1) printf("m > 0\n");
else if(n == m) printf("n != m\n");
}while(m < 1 || m == n);
a = (int**) malloc(sizeof(int*) * n);
for(x = 0; x < n; x++)
a[x] = (int*) malloc(sizeof(int) * m);
q = (int*) malloc(sizeof(int) * n);
srand(time(NULL));
for(x = 0; x < n; x++)
{
q[x] = 0;
for(y = 0; y < m; y++)
{
a[x][y] = rand() % 41 - 20; /* [-20;20] */
printf("%d\t",a[x][y]);
if(a[x][y] > 0) q[x]++;
}
putchar('\n');
}
putchar('\n');
for(x = 0; x < n; x++)
printf("%d\n", q[x]);
putchar('\n');
if(q == (int*) NULL) exit(1);
free(q);
q = (int*) NULL;
if(a == (int**) NULL) exit(1);
for(x = 0; x < n; x++)
{
if(a[x] == (int*) NULL) exit(1);
free(a[x]);
a[x] = (int*) NULL;
}
free(a);
a = (int**) NULL;
return 0;
}