PROGRAM SEGITIGA PADA RUBY
Halo,pada hari ini saya akan membagikan sedikit informasi tentang program segitiga dengan menggunakan
bahasa pemrograman ruby.
Listing :
print "Masukan Rentang segitiga = "
t=gets.to_i
for j in 1..t
for a in 1..j
print " "
end
for b in j..t
print "* "
end
puts
end
for i in 1..t
print " *"
end
puts
for i in 1..t
for x in i..t
print " "
end
for y in 1..i
print "* "
end
puts
end
Output :
=========================================================================
Listing :
print "Masukan Rentang segitiga = "
t=gets.to_i
for j in 1..t
for a in 1..j
print " "
end
for b in j..t
print "* "
end
puts
end
for i in 1..t
print " *"
end
puts
for i in 1..t
for x in i..t
print " "
end
for y in 1..i
print "* "
end
puts
end
Output :
=========================================================================
SEMOGA BERMANFAAT :)
Komentar
Posting Komentar