Advertisement
AmidamaruZXC

Untitled

Feb 7th, 2021
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.39 KB | None | 0 0
  1. var
  2.   x, min, max, digit: integer;
  3.  
  4. begin
  5.   readln(x);
  6.   max := -1;
  7.   min := 10;
  8.   while (x > 0) do
  9.   begin
  10.     digit := x mod 10;
  11.     if (digit mod 2 = 0) and (digit > max) then
  12.       max := digit;
  13.     if (digit mod 2 <> 0) and (digit < min) then
  14.       min := digit;
  15.     x := x div 10;
  16.   end;
  17.   if (max <> -1) then
  18.     writeln(max);
  19.   if (min <> 10) then
  20.     writeln(min);
  21. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement