RUBYの宿題教えてください。at TECH
RUBYの宿題教えてください。 - 暇つぶし2ch652:デフォルトの名無しさん
07/07/09 18:09:50
じゃ、とりあえず。いろいろ宿題の中身無視してるけ、どこんな感じで。

class Array
  def next_pascal
    next_pascal = Array.new

    next_pascal << self[0]

    self[0..-2].each_index do |i|
      next_pascal << self[i] + self[i + 1]
    end

    next_pascal << self[-1]
  end
end

p = [1]

10.times do
  puts p.join(' ')
  p = p.next_pascal
end


最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch