#include<iostream.h>
#include<iomanip.h>
enum error_code{success,overflow,underflow};
typedef struct node{
    int data;
struct node *next;
}node;
class queue{
public:
    queue();
    ~queue();
    bool empty()const;
    error_code get_front(int&x)const;
    error_code append(const int x);
    error_code serve();
private:
    int count;
    node*front,*rear;
};
queue::queue(){
    front=new node;
    rear=front;
    front->next =NULL;
count=0;
}
bool queue::empty ()const{
    return front==rear;
}
error_code queue::get_front (int&x)const{
    if(empty())return underflow;
    x=front->next->data ;
    return success;
}
error_code queue::append (const int x){
    node*s=new node;
    s->data =x;
    s->next =NULL;
    rear->next =s;
    rear=s;
    count++;
    return success;
}
error_code queue::serve (){
    node*u;
    if(empty())return underflow;
    u=front->next ;
    front->next=u->next ;
    delete u;
    count--;
    if(front->next==NULL)rear=front;
    return success;
}
 queue::~queue (){
    while(!empty())serve();
    delete front;}
void fun1(int n){
    int s1,s2;
    queue q;
    int i,j;
    cout<<setw(27)<<1<<endl;
    q.append(1);
    for(i=2;i<=n;i++){
        s1=0;
        cout<<setw(28-2*i);
        for(j=1;j<=i-1;j++){
            q.get_front (s2);
            q.serve ();
            cout<<" "<<s1+s2<<"  ";
            q.append (s1+s2);
            s1=s2;
        }
        cout<<" "<<1<<endl;
        q.append (1);
    }
}
void main()
{
    fun1(8);
}