type
TAbc=Integer;
TStack=record
S:array[1..100]of TAbc;
Top:Integer;
end;
procedure SetNull(var A:TStack);
begin
A.Top:=0;
end;
function pop(var A:TStack):TAbc;
begin
Result:=A.S[A.Top];
Dec(A.Top);
end;
procedure push(var A:TStack;N:TAbc);
begin
Inc(A.Top);
A.S[A.Top]:=N;
end;
function Comp(S:String):TAbc;
var
S1:TStack;
i:integer;
x:TAbc;
ch:char;
begin
S:=S+'@';//以@作为结尾
SetNull(S1);
i:=1;
ch:=S[1];
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:=S;
end;
end;
'+':x:=pop(S1)+pop(S1);
'-':x:=-pop(S1)+pop(S1);
'*':x:=pop(S1)*pop(S1);
'/':begin
x:=pop(s1);
X:=Pop(s1)div x;
end;
end;
push(S1,X);
i:=i+1;ch:=S;
end;
Result:=pop(S1);
end;