Advertisement
Guest User

Untitled

a guest
May 20th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3.  
  4. typedef struct noArv{
  5. int info;
  6. struct noArv *esq;
  7. struct noArv *dir;
  8. } noArv;
  9.  
  10. noArv *criaArv(int valor, noArv *sae, noArv *sad){
  11. noArv *aux;
  12. aux = malloc (sizeof(noArv));
  13. aux->info = valor;
  14. aux->esq = sae;
  15. aux->dir = sad;
  16. return aux;
  17. }
  18.  
  19. void imprimirFolha(noArv *folha){
  20. if (folha != NULL){
  21. if (folha->esq == NULL && folha->dir == NULL){
  22. printf("%d", folha->info);
  23. return;
  24. }
  25. imprimirFolha(folha->esq);
  26. imprimirFolha(folha->dir);
  27. }
  28. }
  29.  
  30. int main(){
  31. noArv *sae, *sad, *folha;
  32. int valor;
  33. for (int i=0;i<5;i++){
  34. criaArv(4, sae, sad);
  35. }
  36. imprimirFolha(folha);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement