-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabela.cpp
More file actions
51 lines (42 loc) · 916 Bytes
/
tabela.cpp
File metadata and controls
51 lines (42 loc) · 916 Bytes
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
#include<iostream>
#include<cstdlib>
#include<ctime>
#include <memory>
#include<cstring>
#include"lista.h"
using namespace std;
int main(){
srand(time(0));
ListaLigada<string> tabela[53];
int i = 0;
int pos;
int aux;
int acumulador=0;
int tamanho_entrada;
int contador=0;
string entrada;
char *char_entrada;
while(cin>>entrada){
acumulador=0;
i=0;
//cout<< "entrada: " << entrada << endl;
char_entrada=&entrada[0];
tamanho_entrada=strlen(char_entrada);
//cout << "Tamanho da entrada " << tamanho_entrada << endl;
while(i<tamanho_entrada){
acumulador = acumulador + (int)char_entrada[i];
i++;
}
//cout << "tamanho da string: " << acumulador << endl;
pos=acumulador%53;
tabela[pos].InsereNoFinal(entrada);
}
i=0;
//Imprimindo tabela hash
cout << "Imprimindo tabela hash" << endl;
while(i<53){
cout << "Posicao " << i<<":" << "\n";
cout << tabela[i];
i++;
}
}