Fandom

Students

Lapis/disciplinas/estruturas de dados:colaborativo

1,331pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

int insereLDSE(pLDSE p, void *dados, int pos) { int i; pNoLDSE aux, aux_novo; if (pos > p->quant+1) pos = 0; if (pos < 0) pos = 1; aux = p->inicio; aux_novo = (pNoLDSE)malloc(sizeof(pNoLDSE)); aux_novo->dados = malloc(p->tamInfo); if (testaVaziaLDSE(p)) { p->inicio = aux_novo; aux_novo->prox = 0; } else if (pos == 0) { for (i=1;i<p->quant;i++) aux = aux->prox; aux->prox = aux_novo; aux_novo->prox = 0; } else if (pos == 1) { aux_novo->prox = p->inicio; p->inicio = aux_novo; } else { for(i=1;i<pos-1;i++) aux = aux->prox; aux_novo->prox = aux->prox; aux->prox = aux_novo; } memcpy(aux_novo->dados,dados,p->tamInfo); p->quant++; return 1; }

int removeLDSE(pLDSE p, int pos) { int i; pNoLDSE aux, ant; if (testaVaziaLDSE(p)) return 0; if (pos > p->quant) pos = 0; if (pos < 0) pos = 1; aux = p->inicio; if (pos == 0) { for (i=1;i<p->quant;i++) { ant = aux; aux = aux->prox; } free(aux->dados); free(aux); ant->prox = 0; } else if (pos == 1) { aux = p->inicio->prox; free(p->inicio->dados); free(p->inicio); p->inicio = aux; } else { for (i=1;i<pos;i++) { ant = aux; aux = aux->prox; } ant->prox = aux->prox; free(aux->dados); free(aux); } p->quant--; return 1; }

Also on Fandom

Random Wiki