arrays and random numbers

a method/function which will sum the rows. if a row is greater than maximum number, decrement a member of the row until the sum drops to maximum
//this is the code i have

public void decrement(int maximum)
{
int rowposition = 0, colposition = 0;

for (int Sum_Rows = 0; Sum_Rows < rows; Sum_Rows++)
{
if (rowsum[rows] > maximum)
{
do
{
rowposition = getRandomNumber(values[rows][rowposition]);
--values[rows][rowposition];
}while ((rowsum[rows] != maximum));//end do while
}//end if
}//end for
sum();
}//end decrement method

Comments

  • [code]
    }while ((rowsum[rows] != maximum));//end
    [/code]

    Just one comment from me at this time. I would change the "!=" to ">" so that the check includes all values greater than maximum instead of just equal to.

    Take Care,
    Ed
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion