Var num: array[1..4] of integer; min, max: integer; begin read(num[1], num[2], num[3], num[4]); min := num[1]; max := num[1]; for var k := 1 to 4 do if num[k] >= max then max := num[k]; for var k := 1 to 4 do if num[k] <= min then min := num[k]; write(max - min); end.
Answers & Comments
Verified answer
Varnum: array[1..4] of integer;
min, max: integer;
begin
read(num[1], num[2], num[3], num[4]);
min := num[1];
max := num[1];
for var k := 1 to 4 do if num[k] >= max then max := num[k];
for var k := 1 to 4 do if num[k] <= min then min := num[k];
write(max - min);
end.