Created
August 29, 2012 09:03
-
-
Save qickstarter/3508837 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -w | |
# 挨拶 | |
greetings = ["おはよう", "おはよう", "こんにちは", "こんばんは", "こんばんは", "おはよう", "こんばんは", "おはよう"] | |
# 挨拶の回数を数えるハッシュ | |
count = Hash.new(0) | |
# 回数を数える | |
greetings.each {|greeting| | |
count[greeting] += 1 | |
} | |
# 回数を表示する | |
count.each {|greeting, ct| | |
puts "#{greeting} : #{ct} 回" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment