Newer
Older
Ruby / shikakkei.rb
@TOGASHI Yuto TOGASHI Yuto on 25 Sep 2021 380 bytes 2021-09-25 04:45:53
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

def shikakkei(tate, yoko)
  if tate <= 0 || yoko <= 0
    return nil
  end
  return tate*yoko
end

puts "長方形または正方形の面積を計算します。"
print "縦の長さを入力:"
tate = gets.to_i
print "横の長さを入力:"
yoko = gets.to_i
printf("この図形の面積は%dです。\n", shikakkei(tate, yoko))