huanglth @ 2017-10-06 11:23:24
type
stack=record
data:array[1..100] of real;
top:0..100;
end;
var
s:stack;
ch:char;
i:longint;
x:real;
a:array[1..30] of char;
function pop(var s:stack):real;
begin
pop:=s.data[s.top];
s.top:=s.top-1;
end;
procedure push(var s:stack;x:real);
begin
s.top:=s.top+1;
s.data[s.top]:=x;
end;
begin
i:=0;
repeat
i:=i+1;
read(a[i]);
until a[i]='@';
s.top:=0;
i:=1;
ch:=a[i];
while ch<>'@' do
begin
case ch of
'0'..'9':begin
x:=0;
while ch<>' ' do
begin
x:=x*10+ord(ch)-ord('0');
i:=i+1;
ch:=a[i];
end;
end;
'+':x:=pop(s)+pop(s);
'-':begin
x:=pop(s);
x:=pop(s)-x;
end;
'*':x:=pop(s)*pop(s);
'/':begin
x:=pop(s);
x:=pop(s)/x;
end;
end;
push(s,x);
i:=i+1;
ch:=a[i];
end;
writeln(pop(s));
end.