#!/usr/bin/env ruby # -*- coding: utf-8 -*- place=Hash.new(0) place["ドイツ"]="ベルリン" place["フランス"]="パリ" place["スイス"]="ベルン" place["フィンランド"]="ヘルシンキ" puts("どこの国が知りたいですか") for name in place.keys printf("%s\n",name) end puts("") where=gets.chomp capital=place[where] if capital==0 printf("%sのデータはありません\n",where) else printf("%sの首都は%sです\n",where,capital) end