Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. void funcCadastro(struct cadastro *aluno);
  5. void funcPrinta(struct cadastro *aluno);
  6. struct cadastro
  7. {
  8.     int ra;
  9.     struct cadastro *prox;
  10. };
  11. void funcPrinta(struct cadastro *aluno)
  12. {
  13.     struct cadastro *atual;
  14.  
  15.     atual = aluno;
  16.  
  17.     if (atual->prox == NULL)
  18.     {
  19.         return;
  20.     }
  21.     atual = atual->prox;
  22.     while (atual != NULL)
  23.     {
  24.        
  25.         printf("\n%d", atual->ra);
  26.         atual = atual->prox;
  27.     }
  28. }
  29. void funcCadastro(struct cadastro *aluno)
  30. {
  31.     struct cadastro *atual;
  32.     struct cadastro *temp;
  33.     int op;
  34.     atual = aluno;
  35.     temp = (struct cadastro*)malloc(sizeof(struct cadastro));
  36.     printf("Digite quantos RA's deseja cadastrar:");
  37.     scanf("%d", &op);
  38.     for (int i = 0; i < op; i++)
  39.     {
  40.  
  41.         printf("\nDigite um ra:");
  42.         scanf("%d", &(aluno->ra));
  43.         temp->prox = NULL;
  44.  
  45.         while (atual->prox != NULL)
  46.         {
  47.             atual = atual->prox;
  48.         }
  49.         atual->prox = temp;
  50.     }
  51.  
  52. }
  53. void main()
  54. {
  55.     struct cadastro aluno;
  56.  
  57.     aluno.ra = -1;
  58.     aluno.prox = NULL;
  59.     funcCadastro(&aluno);
  60.     funcPrinta(&aluno);
  61.     fflush(stdin);
  62.     getchar();
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement