#!/usr/bin/env ruby # coding: utf-8 kotae = 0 i = 0 while i<10 x = rand(900)+100 kotae += x printf("\r%d ", x) sleep(0.8) printf("\r ") sleep(0.2) i += 1 end print "\r答は: " a = gets.to_i if a == kotae puts("正解!!") else printf("ざんねん!!\n正解は %d\n", kotae) end