Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct no{
- int elem;
- struct no*dir, *esq;
- }noArv;
- noArv *insere(noArv *r, int valor){
- noArv *novo = (noArv *) malloc(sizeof(noArv));
- if(r == NULL){
- novo->elem=valor;
- novo->esq = novo->dir = NULL;
- return novo;
- }else{
- if(valor < r->elem){
- r->esq = insere(r->esq, valor);
- }else{
- r->dir = insere(r->dir, valor);
- }
- }
- return r;
- }
- int main(){
- noArv *root = NULL;
- int i;
- for(i=0; i<MAX; i++){
- scanf("%d",&aux);
- root = insere(root,aux);
- }
- preO(root);
- emO(root);
- posO(root);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement