fork(1) download
  1. def print_arr(arr)
  2. arr.each do |inner|
  3. puts inner.join
  4. end
  5. end
  6.  
  7. def print_cross(n)
  8. arr = Array.new(n) { Array.new(n) { ' ' } }
  9. 0.upto(n-1) {|i| arr[i][i] = 'X'; arr[n-1-i][i] = 'X'}
  10. print_arr arr
  11. end
  12.  
  13. print_cross 9
Success #stdin #stdout 0.05s 9704KB
stdin
Standard input is empty
stdout
X       X
 X     X 
  X   X  
   X X   
    X    
   X X   
  X   X  
 X     X 
X       X