+ 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

25th Sep 2017, 7:43 PM
Arun
2 odpowiedzi
+ 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)
25th Sep 2017, 10:01 PM
André
André - avatar