Advertisement
Narzew

Dodawanie zmiennej

Nov 5th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.29 KB | None | 0 0
  1. begin
  2.     print "Podaj pierwsza liczbe: "
  3.     a = $stdin.gets.chomp!.to_i
  4.     print "Podaj druga liczbe: "
  5.     b = $stdin.gets.chomp!.to_i
  6.     print "Podaj operacje: "
  7.     c = $stdin.gets.chomp!
  8.     d = eval("a #{c} b")
  9.     print "#{a} #{c} #{b} = #{d}\n"
  10.     exit
  11. rescue => e
  12.     puts "Error: #{e}\n"
  13.     exit
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement