Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
static struct node
{ int key; struct node *next; };
static struct node *heada, *za, *ta;
static struct node *headb, *zb, *tb;
stackpairinit()
{
heada = (struct node *) malloc(sizeof *heada);
za = (struct node *) malloc(sizeof *za);
heada->next = za; heada->key=0;
za->next = za;
za->key = 0;
headb = (struct node *) malloc(sizeof *headb);
zb = (struct node *) malloc(sizeof *zb);
headb->next = zb; headb->key=0;
zb->next = zb;
zb->key = 0;
}
stackpairflush()
{
free(heada);
free(headb);
free(za);
free(zb);
}
pushpair(pa, pb)
int *pa;
int *pb;
{
int va;
int vb;
va = *pa;
ta = (struct node *) malloc(sizeof *ta);
ta->key = va; ta->next = heada->next;
heada->next =ta;
vb = *pb;
tb = (struct node *) malloc(sizeof *tb);
tb->key = vb; tb->next = headb->next;
headb->next =tb;
}
poppair(xa,xb)
int *xa;
int *xb;
{
ta = heada->next; heada->next = ta->next;
*xa = ta->key;
free(ta);
tb = headb->next; headb->next = tb->next;
*xb = tb->key;
free(tb);
}
stackpairempty(i)
int *i;
{
*i = 0;
if(heada->next == za) *i = 1;
}