С функцией ord:
var
n, d: longint;
begin
readln(n);
n := n - 1;
d :=
(n div 300 + 1) * ord(n mod 3 = 0) +
(n div 3 mod 100 div 10) * ord(n mod 3 = 1) +
(n div 3 mod 10) * ord(n mod 3 = 2);
writeln(d);
readln
end.
Без ord:
dec(n);
(n div 300 + 1) * (1 - (n mod 3 + 1) div 2) +
(n div 3 mod 100 div 10) * (n mod 3 mod 2) +
(n div 3 mod 10) * (n mod 3 div 2);
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
С функцией ord:
var
n, d: longint;
begin
readln(n);
n := n - 1;
d :=
(n div 300 + 1) * ord(n mod 3 = 0) +
(n div 3 mod 100 div 10) * ord(n mod 3 = 1) +
(n div 3 mod 10) * ord(n mod 3 = 2);
writeln(d);
readln
end.
Без ord:
var
n, d: longint;
begin
readln(n);
dec(n);
d :=
(n div 300 + 1) * (1 - (n mod 3 + 1) div 2) +
(n div 3 mod 100 div 10) * (n mod 3 mod 2) +
(n div 3 mod 10) * (n mod 3 div 2);
writeln(d);
readln
end.