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

So, I have been told to find the smallest number in an array, that's what I did
PHP код:
    // Task 1
    
new biggest 0;
    for(new 
0sizeof(Arr); i++) if(Arr[i] > biggestbiggest Arr[i];
    
printf("The highest number is: %d"biggest);
    
// Task 2
    
new smallest biggest;
    for(new 
0sizeof(Arr); i++) if(Arr[i] < smallestsmallest Arr[i];
    
printf("The smallest number is: %d"smallest); 
And my fellow scripter told me that there is another way to do it, instead of run two loops I can run only one
And he gave me a hint to use hexa numbers, anyone's got a clue ?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)