読者です 読者をやめる 読者になる 読者になる

落書きノート

ふと自分が気になった事を書いてます

Rubyで問題を解く

for i in 1..9 do
  for j in 1..9 do
    print sprintf("%3d", i * j)
  end
  puts
end


print "段数は?:"
n = gets.chomp.to_i

for i in 1..n do
  for j in 1..5 do
    print "*"
  end
  puts
end



print "段数は?:"
n = gets.chomp.to_i

for i in 1..n do
  for j in 1..i do
    print "*"
  end
  puts
end




print "段数は?:"
n = gets.chomp.to_i

for i in 1..n do
  for j in 1..n - i + 1 do
    print "*"
  end
  puts
end




print "段数は?:"
n = gets.chomp.to_i

for i in 1..n do
  for j in 1..n - i do
    print " "
  end
  for k in 1..i do
    print "*"
  end
  puts
end




print "段数は?:"
n = gets.chomp.to_i

for i in 1..n do
  for j in 1..i - 1 do
    print " "
  end
  for k in 1..n - i + 1 do
    print "*"
  end
  puts
end