Beispiel #1
0
void heapyfy_pop (int index) {
    int tmp;
    int esq = esquerda(index);
    int dir = direita(index);
    int min_index;
    if (dir >= mh.indiceNo) {
        if (esq >= mh.indiceNo)
            return;
        else
            min_index = esq;
    }
    else {
        if (mh.pesos[esq] <= mh.pesos[dir])
            min_index = esq;
        else
            min_index = dir;
    }

    if (mh.pesos[index] > mh.pesos[min_index]) {
        tmp = mh.pesos[min_index];
        mh.pesos[min_index] = mh.pesos[index];
        mh.pesos[index] = tmp;
        heapyfy_pop (min_index);
    }
}
Beispiel #2
0
void Motores::movimentoAleatorio(int intensidade) {
  int m = random(1,9);
  if(m==1) frente(intensidade);
  if(m==2) re(intensidade);
  if(m==3) esquerda(intensidade);
  if(m==4) direita(intensidade);
  if(m==5) reEsquerda(intensidade);
  if(m==6) reDireita(intensidade);
  if(m==7) girar(intensidade, 0);
  if(m==8) girar(intensidade, 1);
}