Как вернуть наибольшее значение (после total) в 2D массиве?
Hi, I am trying to find the largest value in a 2D array. The 2D array has been populated with numbers that has been entered by users. Each row represents a 'topic'. The function below should loop through the array starting with its row and 10 columns and totalling the result. Please note: I am going through an old C++ book that uses arrays as opposed to improved containers. Thank you in advance!! :)
Что я уже пробовал:
int getHighest(int arr[][10]) { int total = 0; int index; int largest = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 10; j++) { if (responses[i][j] >= 1) { index = j + 1; total += (index * (responses[i][j])); } } if (total > largest) { largest = total; } } return largest; }