Recent Posts
Per | 51 sec ago
None | 1 min ago
None | 1 min ago
T-SQL | 1 min ago
XML | 1 min ago
T-SQL | 1 min ago
None | 1 min ago
Bash | 1 min ago
None | 1 min ago
None | 2 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Jesuino on the 22nd of Jun 2009 12:21:08 PM Download | Raw | Embed | Report
  1. void remover(struct _lista *lista, int pos){
  2.      pos--;
  3.      int atualPos = 0;
  4.      
  5.      while(lista->prev != NULL){
  6.          lista =  lista->prev;
  7.      }
  8.      
  9.      while(atualPos++ != pos && lista != NULL ){
  10.          lista = lista->prox;              
  11.      }
  12.      
  13.      if(lista == NULL){
  14.          printf("Naum ha elemento a remover\n");
  15.          return;
  16.      }
  17.      //Não é o último
  18.      if(lista->prox){
  19.         //Não é o primeiro elemento        
  20.         if(lista->prev){            
  21.            lista->prev->prox = lista->prox;
  22.            lista->prox->prev = lista->prev;              
  23.         }
  24.         //Primeiro elemento
  25.         else{
  26.           printf("%p\n", lista);
  27.           lista = lista->prox;        
  28.           printf("%p\n", lista);
  29.           lista->prev = NULL;          
  30.         }
  31.                
  32.      }
  33.      //Último elemento
  34.      else if(lista->prev){
  35.            lista  = lista->prev;
  36.            lista->prox = NULL;          
  37.      }    
  38.      else{
  39.           printf("este eh o elemento unico da lista...");    
  40.      }
  41. }
Submit a correction or amendment below. [ previous version ] | [ difference ] | Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: