+ 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.
5 Respostas
+ 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.
+ 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
+ 5
https://code.sololearn.com/cq3Sz8rO5HW2/?ref=app
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;
}