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

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

printf("Highest: %d", highest);
printf("Lowest: %d", lowest);
That's the point, I have been asked to get the lowest number, without stating a number beforehand (without lowest = 9999) so it can get the lowest number no matter what the highest is.
Do you know a way to do it ?
I mean doing the Task 2 point without using task1 or stated variables (lowest = X)
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)