pascalabcnet/_Presentations/2015 New Features/Programs/23_Stack1.pas
Бондарев Иван e6e67c193c initial commit
2015-05-14 21:35:07 +02:00

12 lines
244 B
ObjectPascal

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.