Skip to content

Instantly share code, notes, and snippets.

@thiagopnts
Created May 24, 2012 00:41
Show Gist options
  • Save thiagopnts/2778636 to your computer and use it in GitHub Desktop.
Save thiagopnts/2778636 to your computer and use it in GitHub Desktop.
Public class Aluno {
private int mat;
private String nome;
private float CRE;
// constructores e métodos gets e sets
}
Public class TabelaHash {
private Aluno[] tabela;
public static final N = 100;
// constructor
float calculaMedia (int mat) {
int h = mat%N;
Aluno a = tab[h];
int count = 0;
float medias = 0f;
while (a != NULL) {
if (a.getMatricula() == mat) {
medias += a.CRE;
count++;
}
a = a.getProximo();
}
return (count != 0 ? medias/count : medias)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment