30.09.2016, 19:57
So, I have been told to find the smallest number in an array, that's what I did
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 ?
PHP код:
// Task 1
new biggest = 0;
for(new i = 0; i < sizeof(Arr); i++) if(Arr[i] > biggest) biggest = Arr[i];
printf("The highest number is: %d", biggest);
// Task 2
new smallest = biggest;
for(new i = 0; i < sizeof(Arr); i++) if(Arr[i] < smallest) smallest = Arr[i];
printf("The smallest number is: %d", smallest);
And he gave me a hint to use hexa numbers, anyone's got a clue ?