uses crt;
const elemen=100;
type s100 = string[elemen];
tumpukan = record
isi :s100;
atas : 0..elemen;
end;
var t : tumpukan;
i : integer;
kalimat :s100;
procedure awalan(var t:tumpukan);
begin
t.atas := 0;
end;
procedure push(var t:tumpukan; x:char);
begin
t.atas := t.atas + 1;
t.isi[t.atas] := x;
end;
function pop(var t:tumpukan):char;
begin
pop := t.isi[t.atas];
t.atas := t.atas - 1;
end;
{program utama}
begin
clrscr;
awalan(t);
write('===> Ketik Kalimat :'); readln(kalimat);
writeln('******=====================================******');
writeln('===> Kalimat Yang Diinput : ',kalimat);
writeln;
write('===> Setelah Proses, Perubahannya adalah : ');
for i := 1 to length(kalimat) do
push(t,kalimat[i]);
for i := 1 to length (kalimat) do
write(pop(t));
readln;
end.
Tidak ada komentar:
Posting Komentar