uses crt;
(* celociselna kalkulacka
pou§?v prom?nou longint <-2147483648..2147483647>
m - zapis do pameti
M - vypis pameti *)
const tlacitek = 16;
tl_h : array[1..tlacitek] of char =
('7','8','9','4','5','6','1','2','3','0','+','-','*','/','=','C');
tl_x : array[1..tlacitek] of integer =
(2,6,10,2,6,10,2,6,10,6,14,14,14,14,10,2);
tl_y : array[1..tlacitek] of integer =
(5,5,5,7,7,7,9,9,9,11,5,7,9,11,11,11);
plus = 0;
minus = 1;
krat = 2;
deleno = 3;
delka = 15;
procedure color(t,p:byte);
begin
textcolor(t);
textbackground(p);
end;
procedure tlacitko(cislo:byte;c:byte);
begin
color(0,c);
gotoxy(tl_x[cislo],tl_y[cislo]);
write(' '+tl_h[cislo]+' ');
end;
procedure stisk(cislo:byte);
begin
color(0,4);
gotoxy(tl_x[cislo],tl_y[cislo]);
write(' '+tl_h[cislo]+' ');
delay(200);
color(0,1);
gotoxy(tl_x[cislo],tl_y[cislo]);
write(' '+tl_h[cislo]+' ');
end;
procedure status(cislo:longint);
var txt : string[delka];
x : integer;
begin
gotoxy(2,3);
str(cislo,txt);
color(15,0);
for x:=length(txt) to delka-1 do
txt:=' '+txt;
write(txt);
end;
procedure init;
var x : byte;
begin
color(0,15);
for x:=2 to 12 do
begin
gotoxy(1,x);
write(' ');
end;
for x:=1 to tlacitek do tlacitko(x,1);
status(0);
end;
var k : char;
c,cp,m : longint;
posl : byte;
begin
color(15,0);
clrscr;
init;
c:=0;
cp:=0;
posl:=plus;
repeat
k:=readkey;
case k of
'7' : begin
stisk(1);
cp:=cp*10+7;
end;
'8' : begin
stisk(2);
cp:=cp*10+8;
end;
'9' : begin
stisk(3);
cp:=cp*10+9;
end;
'4' : begin
stisk(4);
cp:=cp*10+4;
end;
'5' : begin
stisk(5);
cp:=cp*10+5;
end;
'6' : begin
stisk(6);
cp:=cp*10+6;
end;
'1' : begin
stisk(7);
cp:=cp*10+1;
end;
'2' : begin
stisk(8);
cp:=cp*10+2;
end;
'3' : begin
stisk(9);
cp:=cp*10+3;
end;
'0' : begin
stisk(10);
cp:=cp*10;
end;
'm' : m:=cp;
'M' : cp:=m;
'+','-','*','/',#13 : begin
case posl of
plus : c:=c+cp;
minus : c:=c-cp;
krat : c:=c*cp;
deleno : c:=c div cp;
end;
cp:=0;
case k of
'+' : begin
stisk(11);
posl:=plus;
end;
'-' : begin
stisk(12);
posl:=minus;
end;
'*' : begin
stisk(13);
posl:=krat;
end;
'/' : begin
stisk(14);
posl:=deleno;
end;
#13 : begin
stisk(15);
posl:=plus;
cp:=c;
c:=0;
end;
end;
end;
'C','c' : begin
stisk(16);
c:=0;
cp:=0;
end;
end;
status(cp);
until k=#27;
end.