#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int i, j=1,k, max_val, count=0, max, fl = 0;
cout << "Enter Maximum Number: ";
cin >> max_val;
cout << endl;
max = max_val;
for(k=1; k<=max_val; k++)
{
i = 1;
count = 0;
while(i)
{
if(i < max_val && count == 0)
{
if(i < max)
{
cout << i << " ";
}
i++;
}
else if(i == max_val)
{
count = 1;
i--;
if(fl == 1)
{
if(max == max_val)
{
max--;
cout << " ";
}
else
{
for(j=1; j<= max_val-max; j++)
{
cout << " ";
}
cout << " ";
max--;
}
}
else
cout << max_val << " ";
}
else if(count == 1)
{
if(i-1 < max)
{
cout << i << " ";
}
i--;
}
else if(i == 0)
break;
}
cout << endl;
fl = 1;
}
cout << endl;
system("pause");
}