Skip to content

Instantly share code, notes, and snippets.

@firstspring1845
Created November 5, 2013 07:17
Show Gist options
  • Save firstspring1845/7315135 to your computer and use it in GitHub Desktop.
Save firstspring1845/7315135 to your computer and use it in GitHub Desktop.
逆ポーランド電卓
stack = []
for s in gets.split()
if ['+','-','*','/'].include?s
stack.push(eval(stack.pop.to_s+s+stack.pop.to_s))
else
stack.push(s.to_i)
end
end
puts stack.pop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment