開発環境
- OS X Lion - Apple(OS)
- Emacs、BBEdit - Bare Bones Software, Inc. (Text Editor)
- Ruby (プログラミング言語)
『初めてのプログラミング 第2版』(Chris Pine 著、長尾 高弘 訳、オライリー・ジャパン、2010年、ISBN978-4-87311-469-9)の 2章(数値), 2.5(練習問題)、1年の時間数、を解いてみる。
その他参考書籍
- 『プログラミング言語 Ruby』David Flanagan, まつもと ゆきひろ 著 、卜部 昌平 監訳、長尾 高弘 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-394-4)
- Rubyクックブック ―エキスパートのための応用レシピ集
1年の時間数
コード(BBEdit)
sample.rb
#!/usr/bin/env ruby2.0 #-*- coding: utf-8 -*- day = 24 year = 365 leap_year = 366 puts "1年の時間: #{year * day}時間" puts "(うるう年 #{leap_year * day}時間"
入出力結果(Terminal)
$ ./sample.rb 1年の時間: 8760時間 (うるう年 8784時間 $
ちなみにpython3.3の場合。
コード(BBEdit)
sample.py
#!/usr/bin/env python3.3 #-*- coding: utf-8 -*- day = 24 year = 365 leap_year = 366 print('1年の時間: {0}時間'.format(year * day)) print('(うるう年: {0}時間)'.format(leap_year * day))
入出力結果(Terminal)
$ ./sample.py 1年の時間: 8760時間 (うるう年: 8784時間) $
0 コメント:
コメントを投稿