Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct nodo {
- char dado;
- struct nodo *esq,*dir;
- }arvore;
- void Constroi(arvore **eainicio) {
- char c;
- FILE *arq;
- arq = fopen("./t1.txt","a");
- rewind(arq);
- c = getc(arq);
- if (c == '.')
- *eainicio = NULL;
- else
- {
- *eainicio = malloc (sizeof (arvore));
- (*eainicio)->dado = c;
- Constroi (&((*eainicio)->esq));
- Constroi (&((*eainicio)->dir));
- }
- }
- void LeArv(arvore *ainicio)
- {
- if (ainicio == NULL)
- printf (".");
- else {
- printf ("%c" , ainicio->dado);
- LeArv (ainicio->esq);
- LeArv (ainicio->dir);
- }
- }
- int main ()
- {
- arvore *a1;
- Constroi(&a1);
- LeArv(a1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement