Pattern Inverted Hour Glass

Can anyone send me the correct code,i’ll dry run and understand it,i am stuck in between

@Subrat have A look at this .

1 Like

Better way to do
#include
using namespace std;

int main()
{
int n;
cin>>n;
cout<<endl;
for(int i=n;i>=0;i–)
{
for(int j=n;j>=i;j–)
{
cout<<j<<" “;
}
for(int space=n;space>=2*(n-i)-(n-2);space–)//for(int space=2*i-1;space>=1;space–)
{
cout<<” “;
}
for(int j=i;j<=n;j++)
{
if(j!=0)
cout<<j<<” ";
}

    cout<<endl;
}
for(int i=1;i<=n;i++)
{
    for(int j=n;j>=i;j--)
    {
        cout<<j<<" ";
    }
    for(int space=1;space<=2*i-1;space++)
    {
        cout<<"  ";
    }
   for(int j=i;j<=n;j++)
   {
       cout<<j<<" ";
   }
    cout<<endl;
}

return 0;

}

1 Like

thank you so much for the help

@Subrat If your issue has been resolved please close this doubt