Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Binary-digits/ALGOL-W/binary-digits.alg
Normal file
24
Task/Binary-digits/ALGOL-W/binary-digits.alg
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
begin
|
||||
% prints an integer in binary - the number must be greater than zero %
|
||||
procedure printBinaryDigits( integer value n ) ;
|
||||
begin
|
||||
if n not = 0 then begin
|
||||
printBinaryDigits( n div 2 );
|
||||
writeon( if n rem 2 = 1 then "1" else "0" )
|
||||
end
|
||||
end binaryDigits ;
|
||||
|
||||
% prints an integer in binary - the number must not be negative %
|
||||
procedure printBinary( integer value n ) ;
|
||||
begin
|
||||
if n = 0 then writeon( "0" )
|
||||
else printBinaryDigits( n )
|
||||
end printBinary ;
|
||||
|
||||
% test the printBinaryDigits procedure %
|
||||
for i := 5, 50, 9000 do begin
|
||||
write();
|
||||
printBinary( i );
|
||||
end
|
||||
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue