Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct no{
  5. int value;
  6. struct no *prox;
  7. };
  8.  
  9. typedef struct no celula;
  10. void insere_no(celula *plist, int valor);
  11. void imprime(celula *plist);
  12.  
  13. int main(){
  14. int i;
  15. celula head;
  16. head.prox=NULL;
  17. for(i=0;i<5;i++){
  18. insere_no(&head,i+1);}
  19.  
  20. return 0;
  21. }
  22.  
  23. void insere_no(celula *plist, int valor){
  24. celula *paux;
  25. paux = malloc(sizeof(celula));
  26. paux->prox = plist->prox;
  27. plist->prox = paux;
  28. }
  29.  
  30. void imprime(celula *plist){
  31. if(plist->prox==NULL){
  32. printf(" %d Tchau", plist->value);
  33. return 0;
  34. }
  35. else{
  36. printf("%d", plist->value);
  37. imprime(plist->prox);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement