n = 10 max = 0 min = 99999 i = 1 sum = 0 while i <= n do a = rand( 100 ).to_i printf( "%d番目の乱数は%dです\n" , i , a ); if a < min then min =a; elsif a > max then max =a; end sum += a i += 1 end printf( "-----------\n" ); printf( "最大値は%dです\n" , max ); printf( "最小値は%dです\n" , min ); printf( "平均値は%dです\n" , sum / n );