#!/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))