n = 0; sum = 0; while true do line = gets.chomp if line == "q" then break; else sum += line.to_i n += 1 end end printf( "合計は%d,平均は%dです\n" , sum , sum / n )