# Include <stdio. h>
# Include <stdlib. h>
# Include <bios. h>
# Include <string. h>
# Include <graphics. h>
/* Define global variables */
Int pu = 0, po = 0, t = 0;
Char tp [130] [12];
/* The order in which stacks are arranged in and out of stacks */
Struct train {
Int numb;
Struct train * next;
};
Struct push {
Int;
Int B;
Char data [24];
Struct push * next;
};
Struct push * creat (struct push * top)
{
Top = (struct push *) malloc (sizeof (struct push ));
Top-> next = NULL;
Return top;
}
Struct push * pup (struct push * top, int a, int B, int n)
{
Struct push * p, * q;
Q = top-> next;
P = (struct push *) malloc (sizeof (struct push ));
P-> a =;
P-> B = B;
If (q)
Strcpy (p-> data, q-> data );
If (q-> a <n |! Q)
{
P-> data [a + b-1] = 'R ';
P-> data [a + B] = '';
}
Else
{
P-> data [a + b-1] = 'C ';
P-> data [a + B] = '';
}
P-> next = top-> next;
Top-> next = p;
Return top;
}
Struct push * pop (struct push * top)
{
Top = top-> next;
Return top;
}
Struct push * apaili (struct push * top, int numb)/* move an output command backward */
{
Struct push * q;
Q = top-> next;
If (pu <numb)
{
Pu ++;
Top = pup (top, pu, po, numb );
Top = apaili (top, numb );
}