[boris@fedora27workstation PASCAL]$ cat ConvDecBin.pas
program ConvDecBin;
procedure Dec2Bin(var sbin : string; NUMBER : integer);
begin
if NUMBER > 0 then begin
Dec2Bin(sbin, NUMBER div 2);
if NUMBER mod 2 = 0 then
sbin := sbin + '0'
else
sbin := sbin + '1';
end;
end;
var
j : integer;
s : string;
begin
read(j);
Dec2Bin(s,j);
writeln(s);
end.
[boris@fedora27workstation PASCAL]$ fpc -oConvDecBin.exe ConvDecBin.pas
Free Pascal Compiler version 3.0.2 [2018/03/14] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling ConvDecBin.pas
Linking ConvDecBin.exe
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
22 lines compiled, 0.1 sec
[boris@fedora27workstation PASCAL]$ ./ConvDecBin.exe
285
100011101
No comments:
Post a Comment