def max( x ) max_value = x[ 0 ] (1..x.length-1).each { |i| if max_value < x[ i ] then max_value = x[ i ] end } return max_value end a = [ 5 , 6 , 2 , 3 , 10 , 7 ] printf( "最大値は%dです\n" , max( a ) )