Newer
Older
Ruby / shikaku.rb
@TAKAHASHI Shoma TAKAHASHI Shoma on 6 Jan 351 bytes 2024-01-06 15:22:37
#!/usr/bin/env ruby
# -*- coding:utf-8 -*-

def shikaku(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",shikaku(tate,yoko))