Newer
Older
Ruby / shikaku.rb
@HIROSE Yuzuki HIROSE Yuzuki on 28 Oct 351 bytes 2023-10-28 14:16:47
#!/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))