+ 2
Is it possible in any language to draw this simple pattern. Especially in C++
For n=4 d d d d d d d d d d
2 Antworten
+ 1
Yes, and there are many possible approaches to generating this pattern. As one example (one of many potential ways), this should work in Ruby:
def d_triangle(x)
for i in (1.upto(x-1).to_a) + (x.downto(1).to_a)
print " " * (x - i)
puts (" d" * i)[0..i]
end
end
d_triangle(gets.chomp.to_i)