Hi!
I've got a program to do for class and I'm legitimately stumped on it, so I'd like to ask for some help.
The task goes as follows:
"Write a function that finds the
index(es) of the
largest number (hence not the number itself) in each row of a
two dimensional array MxN.
In the program itself ask for the
dimensions (M and N) to be inputted,
the value of the array (the numbers in each row) and then
call the function to do its thing, and then finally
output the results."
So:
1. Is a "two dimensional array MxN" basically a matrix, where M and N are the number of rows and columns?
This by itself should not be hard for me to make; I just need two for loops with two ints (i and j, for example) in order to enter the numbers.
1 2 3 4
|
for(i=0; i<rows; i++) {
for(j=0; j<columns; j++) {
cout<<"Element ["<<i<<","<<j<<"]:";
cin>>array[i][j];
|
2. How do I make M and N the lengths of the array/matrix, and then have the user input them?
3. How do I determine which index (spot in the array) has the largest number?
4. How do I store that result (the index of the largest number in each row) and then output it? (I know that output is just a simple "cout")
This doesn't sound too hard, yet I'm having troubles with it.
So, any help is appreciated, be it just instructions or actual code examples.
I'll try to tinker with it in the meantime.