Advertisement
Miinsk

LAB 04 - 29-05 QUESTAO 02-A

May 29th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. struct nodo{
  4.     int valor;
  5.     struct nodo *prox;
  6.     struct nodo *ant;
  7. };
  8. /*
  9. void insere_depois_prim(struct nodo *inicio, struct nodo **fim, int v, int *status){
  10.     struct nodo *novo;
  11.     *status = 0;
  12.    
  13.     if(inicio != NULL){
  14.         novo = (struct nodo *) malloc(sizeof(struct nodo));
  15.        
  16.         if(novo!=NULL){
  17.             novo->valor = v;
  18.             novo->prox = inicio->prox;
  19.            
  20.             if(inicio->prox != NULL)
  21.                 (inicio->prox)->ant = novo;
  22.             else *fim = novo;
  23.             inicio->prox = novo;
  24.             novo->ant = inicio;
  25.             *status = 1;
  26.         }
  27.     }
  28. }
  29. */
  30. //Lista sem ptr fim
  31.  
  32. void insere_depois_prim(struct nodo *inicio, int v, int *status){
  33.     struct nodo *novo;
  34.     *status = 0;
  35.    
  36.     if(inicio!=NULL){
  37.         novo = (struct nodo *) malloc(sizeof(struct nodo));
  38.         if(novo!=NULL){
  39.             novo->valor = v;
  40.             novo->prox = inicio->prox;
  41.            
  42.             if(inicio->prox != NULL)
  43.                 (inicio->prox)->ant = novo;
  44.            
  45.             inicio->prox = novo;
  46.             novo->ant = inicio;
  47.             *status = 1;
  48.         }
  49.     }
  50. }
  51.  
  52. mostrar(){
  53.  
  54. }
  55. int main(){
  56.     struct nodo *inicio,*fim;
  57.     int status;
  58.     int valor;
  59.    
  60.     inicio = NULL;
  61.     fim = NULL;
  62.    
  63. //  printf("\nInsira um valor:");
  64. //  scanf("%d",&valor);
  65.    
  66.     insere_depois_prim(&inicio, 20, &status);
  67.    
  68.     mostrar
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement