-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_hash.cpp
85 lines (66 loc) · 2.1 KB
/
main_hash.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include "hash.h"
using namespace std;
int main()
{
int sizeHash, maxItems;
cout << "Programa gerador de hash\n";
cout << "Digite o tamanho da Hash\n";
cin >> sizeHash;
cout << "Digite o numero maximo de elementos!\n";
cin >> maxItems;
cout << "O fator de carga e: " << (float)maxItems / (float)sizeHash << endl;
Hash alunoHash(sizeHash, maxItems);
int opcao;
int id;
string name;
bool busca;
Aluno aluno(id, name);
do{
cout << "Digite 0 para parar o algoritmo!\n";
cout << "Digite 1 para inserir um elemento!\n";
cout << "Digite 2 para remover um elemento!\n";
cout << "Digite 3 para buscar um elemento!\n";
cout << "Digite 4 para imprimir a Hash!\n";
cin >> opcao;
switch (opcao)
{
case 0:
exit(0);
case 1:
cout << "Qual é o id do aluno?" << endl;
cin >> id;
cout << "Qual é o nome do aluno?" << endl;
cin >> name;
aluno = Aluno(id, name);
alunoHash.push(aluno);
break;
case 2:
cout << "Qual é o id do aluno a ser removido?" << endl;
cin >> id;
aluno = Aluno(id, name);
alunoHash.remove(aluno);
break;
case 3:
cout << "Qual é o id do aluno a ser procurado" << endl;
cin >> id;
aluno = Aluno(id, name);
bool find;
alunoHash.find(aluno, find);
if(find)
{
cout << "Aluno encontrado" << endl;
cout << aluno.getId() << " | " << aluno.getName() << endl;
}else{
cout << "Aluno não encontrado" << endl;
}
break;
case 4:
alunoHash.print();
break;
default:
cout << "Opcao inválida!" << endl;
}
}while(opcao != 0 );
return 0;
}