Coding Program Membalik Angka Pada Java
Program Membalik_Angka;
uses
SysUtils;
const maxElemen = 255;
type angka = string [maxElemen];
tumpukan = record
isi: angka;
atas: 0..maxElemen;
end;
var t: tumpukan;
number: angka;
i: Integer;
procedure AWAL (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;
begin
AWAL (t);
writeln(' --------------------------');
writeln(' | PROGRAM MEMBALIK ANGKA |');
writeln(' --------------------------');
writeln;
write('Masukan angka: ');
readln(number);
writeln;
writeln('Angka sebelum dibalik: ');
writeln(number);
writeln;
writeln('Angka sesudah dibalik: ');
for i := 1 to Length(number) do
push (t, number[i]);
for i := 1 to length (number) do
write(POP (t));
Readln;
end.
Comments