Answer the question
In order to leave comments, you need to log in
How to pass an array to a C++ function (writes no matching function to call)?
void average (int *a){
}
int task3(){
int start, rowCount, colCount;
cout << "Enter 1 for inputting numbers from keyboard, or 2 for using random numbers: ";
cin >> start;
cout << "Enter the number of rows and columns" << endl << "Rows: ";
cin >> rowCount;
cout << "Columns: ";
cin >> colCount;
int a[rowCount][colCount];
if (start == 1 ){
for (int i=0; i<rowCount; i++)
for (int j=0; j<colCount; j++)
{cout << "a[" << i << "][" << j << "]="; cin >> a[i][j];}
}
else if (start == 2) {
int Low = -100;
int High = 100;
srand((unsigned) time(NULL));
for (int i = 0; i < rowCount; i++){
for (int j = 0; j < colCount; j++)
a[i][j] = Low + rand() % (High - Low + 1);}
average(a);
}
Answer the question
In order to leave comments, you need to log in
Using the Crosses, it is worth using their conveniences.
std::vector< std::vector< int > > a(rowCount, std::vector< int >(colCount, 0));
void average (std::vector< std::vector< int > > &a){
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question