Jump to content
Fórum Script Brasil
  • 0

lista encadeada simples


tahinf

Question

dado o numero, tenho q removê-lo da lista todas as ocorrẽncias do elemento...

se eu digito 1, 2, 2, 2, 2, 3

e coloco p excluir o 2, aparece certo o numero de vezes que tem o 2, mas na hora de excluir, não tá dando certo, aparece q tm esses numeros na lista

3 , 4072688, 4072656, 1

int remove_lista_exer9 (def_lista* Lista, int numero)

{ k=0;

   def_lista aux=*Lista;

   def_lista ant=NULL;
   def_lista help=NULL;



   while (aux!=NULL)

   { 
         if (aux->info == numero)
   {
        
        help = ant->prox;
        
       ant->prox = aux->prox;
        
        free(aux);
        
        
        k++;
        
        
   }
        else 
   {
    ant=aux;

    aux=aux->prox;
   }
  
   }
   
   
   return k;

}

      ...................   
      
         case 12:   printf("numero a ser retirado da lista");

                scanf("%d",&numero);

                    remove_lista_exer9(&L,numero);

                   printf("\nEncontrou o numero foi retirado %d vezes \n",k);
                break;

Edited by tahinf
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...