#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

a = 1
f = 0
g = 0
printf("-------------------------\n")
printf("     計算クイズアプリ    \n")
while true
  printf(" 第%s問",a)
  srand()
  b = rand(20) + 1
  srand()
  c = rand(20) + 1
  d = b + c
  printf("  %s+%s=? ",b,c)
  e = gets.to_i
  if e == d
    printf("\n正解!\n\n")
    f = f + 1
  else
    printf("\n不正解…答えは%sです。\n\n",d)
    g = g + 1
  end
  a = a + 1
  sleep(0.5)
  if a == 11
    break
  end
end
printf(" 正解[%s問] 不正解[%s問]\n",f,g)
printf("-------------------------\n")

    
  
