Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int lista_retira_meio(lista &l, std::string &s)
- {
- if(l.tamanho == 0) return -1;
- nodo *aux=l.inicio, *ant = nullptr;
- int n = l.tamanho /2;
- if(l.tamanho % 2 == 0) n--;
- for(int i=0; i<n; i++){
- ant = aux;
- aux = aux->elo;
- }
- if (l.inicio==l.fim) //UNICO NODO
- l.inicio=l.fim=nullptr;
- else {
- if (aux==l.inicio) //PRIMEIRO NODO
- l.inicio=l.inicio->elo;
- else ant->elo = aux->elo;
- if (aux==l.fim) //ULTIMO NODO
- l.fim=ant;
- }
- s = aux ->info;
- delete aux;
- l.tamanho--;
- return n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement