def reverse( x ) ( x.length / 2 ).times { |i| work = x[ x.length-1-i ] x[ x.length-1-i ] = x[ i ] x[ i ] = work } end a = [ 3 , 6 , 2 , 4 , 10 , 7 ] reverse( a ) a.length.times { |i| printf( "%d " , a[ i ] ) } printf( "\n" )