Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int contarfolhas(NO *F){
- if(!F)
- return 0;
- if(!F->esq && !F->dir)
- return 1;
- return contarfolhas(F->esq) + contarfolhas(F->dir);
- }
- int EFolha(NO *F){
- if(!F)
- return 0;
- if(!F->esq && !F->dir)
- return 1;
- else
- return 0;
- }
- int contarPREFolhas(NO *F){
- if(!F)
- return 0;
- int contar = 0;
- if( EFolha(F->esq) || EFolha(F->dir))
- contar++;
- return contar + contarPREFolhas(F->dir) + contarPREFolhas(F->esq);
- }
- int alturaDaArvore(NO *F){
- if(!F)
- return 0;
- if( !F->esq && !F->dir)
- return 1;
- if(alturaDaArvore(F->Esq) > alturaDaArvore(F->Dir)){
- return 1+alturaDaArvore(F->Esq);
- }
- else
- return 1+alturaDaArvore(F->Dir);
- }
- typedef struct{
- float NotaAluno;
- char NomeAluno[69];
- NO_Lista *Seguinte;
- }NO_Lista;
- typedef struct{
- int NumAlunos;
- NO_Lista *Topo;
- }Lista;
- typedef struct{
- int Nota;
- Lista *LNomes;
- }NO_Hashin;
- typedef struct{
- NO_Hashin Vector[21]; //0-20 vlaores
- }Hashin;
- int MaisNota(Hashin *Tabela)
- {
- if(!Tabela)
- return 0;
- int MaisNota = 0;
- int aux = 0;
- for(int i = 0; i<20;i++){
- if(Tabela.Vector[i].LNomes->NumAlunos > aux){
- MaisNota = Tabela.Vector[i].Nota;
- aux = Tabela.Vector[i].LNomes->NumAlunos;
- }
- }
- return MaisNota;
- }
- void RecolocarAluno(NO_Lista *Ant, NO_Lista *Recolocar, NO_Lista *Topo){
- if(!Ant || !Recolocar)
- return;
- Ant->Seguinte = Recolocar->Seguinte;
- if(!Topo){
- Topo = Recolocar;
- Recolocar->Seguinte = NULL;
- return;
- }
- NO_Lista *aux = Topo;
- while(aux->Seguinte){
- aux = aux->Seguinte;
- }
- aux->Seguinte = Recolocar;
- Recolocar->Seguinte = NULL;
- }
- void ReduzirChumbos(Hashin *Tabela){
- if(!Tabela)
- return;
- NO_Lista aux = ant = NULL;
- for(int i = 8;i<10;i++){
- aux = ant = Tabela.Vector[i].LNomes->Topo
- while(aux){
- if(aux->NotaAluno > 8.5 && aux->NotaAluno < 9.5 )
- aux->NotaAluno += 0.3;
- if(aux->NotaAluno>=i+1){
- RecolocarAluno(ant,aux,Tabela.Vector[i+1].LNomes->Topo);
- Tabela.Vector[i].LNomes->NumAlunos--;
- Tabela.Vector[i+1].LNomes->NumAlunos++;
- }
- ant = aux;
- aux = aux->Seguinte;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement