Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.66 KB | None | 0 0
  1.     //BIBLIOTECAS
  2.     #include<stdio.h>
  3.     #include <stdlib.h>
  4.      
  5.     //Estrutura ALUNO
  6.     typedef struct ALUNO
  7.             {
  8.                     int matricula;
  9.                     char* nome;
  10.                     int idade;
  11.                     struct ALUNO *prox;
  12.                     struct ALUNO *ant;
  13.             } ALUNO;
  14.      
  15.     void Imprime(ALUNO *L)
  16.     {
  17.             ALUNO *p;
  18.             p = L;
  19.             p = p->prox->prox;
  20.             while (p != NULL)
  21.             {
  22.                     printf("Matricula: %d \n",p->matricula);
  23.                     printf("Nome: %s \n",p->nome);
  24.                     printf("Idade: %d \n \n",p->idade);    
  25.                     p = p->prox;  
  26.             }              
  27.     }
  28.      
  29.     int main()
  30.     {
  31.         //teste Imprime----------------------------------------------------
  32.     ALUNO aluno,aluno1,aluno2,aluno3;
  33.     ALUNO *L;
  34.     aluno.matricula = 0;
  35.     aluno.nome = NULL;
  36.     aluno.idade = 0; //aluno e o no-cabeca 
  37.     aluno1.matricula = 0001;
  38.     aluno1.nome = "Ramon";
  39.     aluno1.idade = 23; 
  40.     aluno2.matricula = 0002;
  41.     aluno2.nome = "Rodrigo";
  42.     aluno2.idade = 21;
  43.     aluno3.matricula = 0003;
  44.     aluno3.nome = "Victor";
  45.     aluno3.idade = 25; 
  46.     L = (ALUNO *) malloc(sizeof(ALUNO));
  47.     L->prox= &aluno;
  48.     L->ant= NULL;
  49.     L = (ALUNO *) malloc(sizeof(ALUNO));   
  50.     L->prox->prox= &aluno1;
  51.     L->prox->ant= &aluno;  
  52.     L = (ALUNO *) malloc(sizeof(ALUNO));
  53.     L->prox->prox->prox= &aluno2;  
  54.     L->prox->prox->ant= &aluno1;
  55.     L = (ALUNO *) malloc(sizeof(ALUNO));
  56.     L->prox->prox->prox->prox= &aluno3;
  57.     L->prox->prox->prox->ant= &aluno2;
  58.  
  59.     Imprime(L);
  60.     //FIM TESTE--------------------------------------------------------------
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement