program stackkkkk;
uses wincrt;
type stack=record
isistack:array [1..100] of integer;
top:integer;
end;
const n:integer=100;
procedure createstack(var s:stack);
begin
s.top:=0;
end;
function isfull(s:stack):boolean;
begin
isfull:=(s.top=n);
end;
function isempty(s:stack):boolean;
begin
isempty:=(s.top=0);
end;
procedure push(var s:stack;x:integer);
begin
if not isfull(s) then
begin
s.top:=s.top+1;
s.isistack[s.top]:=x;
end;
end;
procedure pop(var s:stack;x:integer);
begin
if not isempty(s) then
begin
x:=s.isistack[s.top];
s.top:=s.top-1;
end;
end;
procedure biner(x:integer;var s:stack);
var
a,z:integer;
begin
a:=x;
repeat
begin
z:=a mod 2;
push( s ,z );
a:=a div 2;
end
until (a = 1);
push( s,a);
end;
var
s:stack;
x,a:integer;
begin
readln(x);
biner (x,s);
repeat
begin
pop (s,a);
writeln(a);
end
until s.top=0;
end.
No comments:
Post a Comment