for my c++ class one of the questions ask to take scores from an array(its a 3 by 4) and to see which one is the greatest in each row and each column….its really simple but I have completely spaced how to take the numbers from the array and compare two of them at a time. If you can help please do!!! Thanks!
C++ taking data from an array?
this is all there is to it...
int x=0, y=0;
int array[3][4];
int num1, num2;
num1=array[x][y];
num2=array[x][y+1];
if(num1 %26gt; num2)
{
//...do something
}
Reply:This sounds like a rather easy thing to do. Here's a link to some relevant code, taking the two-dimensional array 'scores' and outputting the maximum to the arrays 'rowmax' and 'colmax':
http://pastebin.com/m1d0e1058
No guarantees, though; I'm new to C++ too. And even if this code does work, there might be a more efficient way to do it.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment