Pattern Mountain

#include
using namespace std;
int main() {
int a,i,j,k,m;
cin>>a;
for(i=1;i<=a;i++)
{
for(m=1;m<=a-i;m++)
{
cout<<" ";
}
for(k=i;k>=1;k–)
{
cout<<k;
}
cout<<endl;
}

return 0;

}
if this is the code tthen it give deried output i.e.
1
21
321
4321
but when i add another loop in between i and m i.e
for(i=1;i<=a;i++)
{
for(j=1;j<=i;j++)
{
cout<<j;
}
for(m=1;m<=a-i;m++)
{
cout<<" ";
}
then it gives me output:
1 1
12 21
123 321
12344321
rhat is the problem?

@Sheenagoyal21
hey seena
this is not right logic
this problem have very easy solution
the left pattern
for i =1 to i<=n
for j =1;j<=i
the space logic
j=1 to 2*(n-i)-1
the last print pattern
j=1;j<=1;j–
if(j!=n)
cout<<j;

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

I just don’t get it.what u r trying to say.can u explain me in detail?

1 Like

The photos that u have sent are not opening please post it again with explanation

@Sheenagoyal21 hey seena please see this.

Can you give me this program input.