Pattern Inverted HourGlass

https://ide.codingblocks.com/#/s/28578

in this question one zero is extra.please resolve

Please give the question link.

https://hack.codingblocks.com/contests/c/509/1418

https://ide.codingblocks.com/#/s/29522

i have made the required changes…

1 Like

#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;

}

A better way to do it

this is wrong solution. check it

try this for values greater than 10. I shows error.