+ 1

How to print this method

1***** 12**** 123*** 1234** 12345*

27th Feb 2018, 4:33 PM
The Programmer The Programmer
The Programmer The Programmer - avatar
4 Respuestas
+ 19
1)run an outer loop from n=1 to n=n 2)inner loop 1 : for int a=1;a <=n;a++ ... print a 3)inner loop 3 : for int b=6-n; while (b--!=0) print "*" 4)then jump to nextline using "\n"
27th Feb 2018, 6:13 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 4
In C++ #include <string> #include <iostream> int main() { std::string txt(6, 42); for(unsigned int i = 0; i < 5; i++) { txt[i] = char(i + 49); std::cout << txt << "\n"; } return 0; } By the way, if this was a challenge, why not submit this as an assignment in Lesson Factory, there goes most challenges nowadays : )
27th Feb 2018, 5:41 PM
Ipang
+ 1
outer_loop: 1-5 inner_loop: 1-outer_loop and 6 minus outer_loop for "*" Python3: for i in range(1,6): for j in range(1,i+1): print(j, end='', sep='') for j in range(6-i): print('*', end='') print('')
27th Feb 2018, 4:39 PM
Rahul Singh
Rahul Singh - avatar
0
talk is cheap show me the code!!
20th Aug 2018, 4:35 PM
The Programmer The Programmer
The Programmer The Programmer - avatar