Skip to content

Instantly share code, notes, and snippets.

@thiagopnts
Created May 24, 2012 01:04
Show Gist options
  • Save thiagopnts/2778744 to your computer and use it in GitHub Desktop.
Save thiagopnts/2778744 to your computer and use it in GitHub Desktop.
public class Cliente {
private int codigo;
private String nome;
private float saldo;
//construtores e metodos gets e sets
}
public class TabelaHash {
private Cliente[] tabela;
public static final int N = 100;
float busca(int codigo) {
int h = codigo%N;
int count = 0;
Cliente cli = tabela[h];
while(cli != NULL && count < N) {
if(cli.getCodigo() == codigo) {
cli.saldo = (cli.saldo * 0.05) + cli.saldo;
return cli.saldo;
}
cli = tabela[++h%N];
count++;
}
return 0f;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment