-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpilhaA.h
50 lines (42 loc) · 782 Bytes
/
pilhaA.h
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
#ifndef PILHA_H_INCLUDED
#define PILHA_H_INCLUDED
typedef struct noa
{
int puzzle[3][3];
struct noa *prox;
}NoA;
typedef struct pilhaa
{
NoA *Topo;
}PilhaA;
PilhaA* CriaPilhaA (void)
{
PilhaA *p;
p=(PilhaA*)malloc(sizeof(PilhaA));
p->Topo = NULL;
return p;
};
NoA* ins_ini (NoA* t, int addedPuzzle[3][3])
{
NoA* aux = (NoA*) malloc(sizeof(NoA));
memcpy(aux->puzzle, addedPuzzle, sizeof(aux->puzzle));
aux->prox = t;
return aux;
};
void push (PilhaA* p, int addedPuzzle[3][3])
{
p->Topo = ins_ini(p->Topo,addedPuzzle);
};
PilhaA * liberaA (PilhaA* p)
{
NoA *q = p->Topo;
while (q!=NULL)
{
NoA* t = q->prox;
free(q);
q = t;
}
free(p);
return(NULL);
};
#endif // PILHA_H_INCLUDED