Created
May 24, 2012 00:41
-
-
Save thiagopnts/2778636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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