Find last largest integer in array?
I am having trouble writing code that will print the last index of the last largest integer an a array. I can get it to print the first index of the largest but if I have two of the largest number in the array I want it to print the last index of the largest and not the first.
I am searching a table but the code really pertains to an array that is within a for loop.
What I am looking to get is the following. If a certain row in the table is 10 10 10 10 10 I would like it to print the last index 4 and not 0.
int findlastlarge(int** table, int numrows, int numcols)
// local declarations
// print title
printf("g. The various last indices of the largest int for each and every row is:\n");
// finds the odd values in each row
for (j = 0; j < numrows; j++)
int largest = INT_MIN;
for (i = 0; i < numcols; i++)
if (table[j][i] > largest)
largest = table[j][i];
large = i;
printf(" %d\n", large);