вектор пока не изучал, не получается((
исправил так:
но не работает((subscripted value is not an array))
void average(int *aarray, int rowcount, int colcount){
int s;
int counter;
for (int i=0; i<rowcount; i++) {
for (int j=0; j<colcount; j++) {
if (aarray[i][j] >0 ){
s += aarray[i][j];
counter++;
}
}
}
}
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 < rowCounti++){
for (int j = 0; j < colCount; j++)
a[i][j] = Low + rand() % ; (High - Low + 1);}
}
average(*a,rowCount,colCount);
}
Написано
Войдите на сайт
Чтобы задать вопрос и получить на него квалифицированный ответ.
исправил так:
но не работает((subscripted value is not an array))