Newer
Older
Ruby / capital.rb
@NARITA Reo NARITA Reo on 19 Mar 2022 477 bytes 2022-03-19 07:58:47
#!/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