Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 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. int 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. imprime(head.prox);
  21. return 0;
  22. }
  23.  
  24. void insere_no(celula *plist, int valor){
  25. celula *paux;
  26. paux = malloc(sizeof(celula));
  27. paux->prox = plist->prox;
  28. plist->prox = paux;
  29. }
  30.  
  31. int imprime(celula *plist){
  32. if(plist->prox==NULL){
  33. printf(" %d Tchau", plist->value);
  34. return 0;
  35. }
  36. else{
  37. printf("%d", plist->value);
  38. imprime(plist->prox);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement