There is a problem that I solved in theory, but the value in the temp array does not change. What is the catch?
=begin Заполнить квадратную матрицу размера n на n натуральными числами от 1 до n**2 в указанном порядке: | 1 2 3 | | 6 5 4 | | 7 8 9 | =end glob_arr = [] temp = [] puts "Введите n" n = gets.chomp.to_i for i in 1..n temp<<i end for i in 0..n-1 if i%2==0 glob_arr << temp else glob_arr << temp.reverse end temp.reverse.each{ |e| e+=1 } end glob_arr.each { |e| puts e.to_s }