-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestao_4.cpp
56 lines (47 loc) · 941 Bytes
/
questao_4.cpp
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
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1 << 20;
int tam;
struct cliente
{
string nome, cpf;
};
cliente* criar()
{
cliente *lista;
lista = (cliente*)(malloc(MAX));
return lista;
}
void inserir(cliente *lista, cliente c)
{
lista[tam] = c;
tam++;
}
cliente remover(cliente *lista)
{
cliente aux = lista[0];
for(int i = 0; i < tam - 1; i++)
lista[i] = lista[i + 1];
return aux;
}
void deletar(cliente *lista)
{
free(lista);
}
int main()
{
cliente *lista = criar();
cliente c1, c2, c3, c4;
c1.nome = "alguem", c1.cpf = "123456789";
inserir(lista, c1);
c2.nome = "mais alguem", c2.cpf = "912345678";
inserir(lista, c2);
c3 = remover(lista);
cout << c3.nome << '\n';
c4.nome = "loucura", c4.cpf = "0000000000";
inserir(lista, c4);
c3 = remover(lista);
cout << c3.nome << '\n';
deletar(lista);
return 0;
}