x = [ 0 , 0 , 0 , 0 , 0 , 0 ] 1000.times{ |i| dice = rand( 6 ) + 1 x[ dice-1 ] += 1 } x.length.times { |i| printf( "%dの出現回数は%d回です\n" , i+1 , x[ i ] ) }