0

How to make triangle of and(&) pattern in any programming language?

which language is better...

13th Nov 2016, 7:08 AM
sanket jain
sanket jain - avatar
6 Antworten
+ 5
oops sorry try this w=20 char="&" m_char=" " print(char.center(w+1)) for i in range(1,w//2): print((char + m_char*(2*i-1)+char).center(w+1)) print(char*(w+1))
13th Nov 2016, 3:01 PM
Sunera Avinash
Sunera Avinash - avatar
+ 2
do you mean a triangular pattern made of & if that is what you asked I think this will work (python3) change values of w and char to change it w=20 char="&" for i in range(w//2): print((char*(2*i+1)).center(w))
13th Nov 2016, 1:41 PM
Sunera Avinash
Sunera Avinash - avatar
+ 2
like this? w=20 char="&" for i in range(w): print(char*(i+1))
13th Nov 2016, 2:37 PM
Sunera Avinash
Sunera Avinash - avatar
+ 2
thax for the logic
13th Nov 2016, 3:45 PM
sanket jain
sanket jain - avatar
+ 1
i want & symbol only on the boundaries of triangle not the one you have given
13th Nov 2016, 2:33 PM
sanket jain
sanket jain - avatar
+ 1
& & & & & & & &&&&&&&&&& like this
13th Nov 2016, 2:43 PM
sanket jain
sanket jain - avatar