A
A
ashot_powershot2021-12-26 13:02:51
C++ / C#
ashot_powershot, 2021-12-26 13:02:51

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

1 answer(s)
R
Rsa97, 2021-12-26
@ashot_powershot

sqrt is a function with one parameter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question