+ 5

{CHALLENGE} Print the following patterns in c++

1 23 345 4567 56789 AND 33 37 41 45 21 25 29 13 17 9 There must be a good logic in your code and the code should be as short as possible.

10th Feb 2018, 3:14 PM
Dev Dutt
Dev Dutt - avatar
5 Respuestas
+ 5
https://code.sololearn.com/cJ092oDRt3jM Btw, "as short as possible" is NOT an indicator for good code. Always keep in mind that empty lines improve readability and that you should also keep space for comments.
10th Feb 2018, 5:19 PM
Chris
Chris - avatar
+ 5
Here's my try. The code is longer and there's less logic than in others' codes, but it works normally😊 https://code.sololearn.com/c26kSxbPkK7C/?ref=app
10th Feb 2018, 6:07 PM
Tim Thuma
Tim Thuma - avatar
+ 5
https://code.sololearn.com/cq3Sz8rO5HW2/?ref=app
18th Feb 2018, 8:36 AM
...
0
#include<iostream> using namespace std; in main() { int n,i,j; cout<<"Enter the value Of n"<<endl; cin>>n; cout<<"The Required Pattern is :"<<endl; i=1; while(i<=n) { j=1; int count = i; while(j<=i) { cout<<count<<" "; count++; j++; } cout<<endl; i++; } return 0; }
5th Dec 2022, 5:47 PM
Pavit Saxena
Pavit Saxena - avatar