+ 2
Write a program to print the pattern like this👇
1 1 1 1 1 2 2 2 2 3 3 3 4 4 5
6 odpowiedzi
+ 3
Better try this code
https://code.sololearn.com/cmEt2YuIi1V1/?ref=app
+ 2
@sapphire yes,it's just like an assignment.well try this in Python language
+ 1
Is this for an assignment?
Which language? Python or c++? Both have drastically different approaches. Or, are you just looking for advice for how to approach it?
+ 1
@sapphire actually i want code.coming to languages it's ur wish..
+ 1
You're the one who posted tags "python" and "c++".
I'm not going to write code if the language choice is not given. Python's method of doing this can be done in 2-3 lines whereas c++ will take quite a few more. Plus, without being told why you need this (sounds like an assignment), I'll just tell you what's needed:
1) The best approach is to probably start with the maximum value you want to reach to (5 for example).
2) Then have another variable that we'll use as a take away from the starting value (it'll start at 1).
3) Create a loop where takeAway <= start
4) My next approach would be turn the "take away" variable into a string, then multiply that string by (start + 1 - takeAway). Don't forget to use formatting to add spaces between each value. Then end with a next line.
5) Add takeAway by 1.
This will effectively draw on the console what you requested.
0
Always is better if you try and ask about your doubts
https://code.sololearn.com/cFt9vn2bVh1f/?ref=app