>>585
問1. http://codepad.org/bJ6EoLbs
問2. http://codepad.org/yL3GPisT
問3. (問2. から拡張) http://codepad.org/x02bRXxM