How to find the smallest number in an array ?
#6

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
pawn Код:
new array[] = {3, 7, 2, 4, 5, 8, 2, 9, 2, 1, 3, 5, 6, 7}, lowest = array[0];
for(new i = 1; i < sizeof(array); i ++)
{
    if(array[i] < lowest)
    {
        lowest = array[i];
    }
}

printf("Lowest: %d", lowest);
You have to initialize the variable, because it starts at 0. Now it should work regardless of what the highest number is.
That should make it, I would have repped you if I could I just did it too soon xD
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)