Archived
1
0
Fork 0
This repository has been archived on 2023-11-10. You can view files and clone it, but cannot push or open issues or pull requests.
SLOTH/examples/minmax.sl

28 lines
425 B
Text
Raw Normal View History

2018-09-18 22:50:15 -04:00
% find the smallest and largest of a set of numbers
% get the amount of numbers to input
N := input;
min := 99999999;
max := 0 - 99999999;
while N > 0 do begin
% get the next number
x := input;
% check if it's the min
if x < min then
min := x; % set it
% check if it's the max
if x > max then
max := x; % set it
% keep counting
N := N - 1;
end
% print the min and max
print min;
print max;