pascalabcnet/_Presentations/2015 New Features/Programs/23_Stack1.pas

12 lines
244 B
ObjectPascal
Raw Permalink Normal View History

2015-05-14 22:35:07 +03:00
begin
var s := '23 6 72 * +';
var st := new Stack<integer>;
foreach var w in s.ToWords do
case w[1] of
'0'..'9': st.Push(w.ToInteger);
'+': st.Push(st.Pop+st.Pop);
'*': st.Push(st.Pop*st.Pop);
end;
writeln(st.Pop);
end.