Задание: Функция заполняет массив случайными числами после чего основная программа ищет кол-во элементов больше заданного по главной диоганали:
Ошибки вот такие компилятор выдает:
In function 'int func(int*, int, int)':
[Error] invalid types 'int[int]' for array subscript
[Error] invalid types 'int[int]' for array subscript
на вот эти строки в прототипе
array[i][j] =rand()%25-5; cout<<array[i][j]<<" ";
#include <iostream>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
#include <clocale>
using namespace std;
int func(int * array, int dim1, int dim2)
{
srand(time(NULL));
for (int i = 0; i< dim1; i++)
{
for (int j = 0; j<dim2; j++)
{
array[i][j] =rand()%25-5;
cout<<array[i][j]<<" ";
}
cout << '\n';
}
return *array;
}
int main()
{
int max,col=0;
int m[5][5];
func((int*)m,5,5);
cout<<"Введите максимальный элемент"<<endl;
cin>>max;
for (int i=0;i<5;i++)
{
cout<<"m[i][i]="<<m[i][i]<<endl;
if((m[i][i]>=0)and (m[i][i]>max)) col++;
}
cout<<"Кол-во="<<col<<endl;
}
and
.