I need help with a function that finds the line with the largest number of numbers in a two-dimensional array and prints index this row. I don't know how to start for help thank you.
main.c
int array[2][2]= { {1,0}, {0,-3} };
printf("%d\n", largest_line(2, array));
int largest_line(const int size, int array[][size]){
for(int col= 0; col < size; col ){
for(int row = 0; row <size; row ){
// and on this place I stop
}
}
}
CodePudding user response:
Something like this should work for you:
int largest_line(const int size, int array[][size]){
int largest_number = 0;
int largest_row = 0;
for(int col= 0; col < size; col ){
for(int row = 0; row <size; row ){
if(largest_number > array[col][row]) {
largest_number = array[col][row]);
largest_row = row;
}
}
}
return largest_row;
}