Answer the question
In order to leave comments, you need to log in
Why is the root revolting?
What does he not like about line 34 and how to fix it?
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<conio.h>
#include<ctime>
#include<windows.h>
#include <stdlib.h>
using namespace std;
int main()
{
//9. Создать двумерные динамические массивы, выделить память и в конце освободить память.
//Дан двумерный массив a, размером (n*m).
//Заполнить одномерный массив, найдя среднее геометрическое положительных элементов в каждом столбце матрицы.
setlocale(0, "");
const int n = 6, m = 7;
int ** a = new int*[n], *b = new int[m], i, j, o=1, g=0;
for (i = 0; i < n; i++)
{
*(a + i) = new int[m];
}
srand(time(NULL) * 1000);
cout << "Массив a" << endl;
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
{
*(*(a + i) + j) = rand() % 20 - 10;
cout << *(*(a + i) + j) << "\t";
if (*(*(a + i) + j) > 0)
{
*(b + g) = sqrt(*(*(a + i) + j), o);
o++;
g++;
}
}
cout << "\n";
}
cout << endl;
cout << endl;
cout << "\n";
cout << "Массив b" << endl;
for (i = 0; i < g; i++)
cout << *(b + i) << "\t" << endl;
for (i = 0; i < n; i++)
delete[] a[i];
system("pause");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question