+ 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

16th Nov 2017, 3:45 AM
looper
looper - avatar
6 odpowiedzi
2nd Dec 2017, 6:25 PM
GEETANJALI PRUDHVI
+ 2
@sapphire yes,it's just like an assignment.well try this in Python language
16th Nov 2017, 5:11 AM
looper
looper - avatar
+ 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?
16th Nov 2017, 3:51 AM
Sapphire
+ 1
@sapphire actually i want code.coming to languages it's ur wish..
16th Nov 2017, 4:03 AM
looper
looper - avatar
+ 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.
16th Nov 2017, 4:45 AM
Sapphire
0
Always is better if you try and ask about your doubts https://code.sololearn.com/cFt9vn2bVh1f/?ref=app
16th Nov 2017, 5:10 AM
Daniel
Daniel - avatar