uses crt;
type
stack1 = record
kalimat:string[255];
top:integer;
end;
var data : stack1;
tampung:string;
j:integer;
procedure push (kar: char; idx: byte);
begin;
data.kalimat[idx]:=kar;
data.top := idx;
end;
function pop : char;
var s:char;
i:byte;
begin
s := data.kalimat[data.top];
data.kalimat[data.top] := ' ';
i := data.top;
data.top := i - 1;
pop := s;
end;
begin
clrscr;
write('masukkan suatu kalimat :'); readln (tampung);
for j := 1 to length(tampung) do
begin
push (tampung[j],j);
end;
for j := 1 to length(tampung) do
begin
write(pop);
end;
readln;
end.
Tidak ada komentar:
Posting Komentar