x = [ 0 , 0 ] 1000.times{ |i| if rand >= 0.5 then x[ 0 ] += 1 else x[ 1 ] += 1 end } printf( "0.5以上の回数は%d回,未満の回数は%d回です\n" , x[ 0 ] , x[ 1 ] )