Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- #include <locale.h>
- #include <wchar.h>
- using namespace std;
- struct nodo
- {
- int nro;
- struct nodo *izq, *der;
- };
- typedef struct nodo *abb;
- abb crearNodo(int x)
- {
- abb nuevoNodo = new(struct nodo);
- nuevoNodo->nro = x;
- nuevoNodo->izq = NULL;
- nuevoNodo->der = NULL;
- return nuevoNodo;
- }
- void insertar(abb &arbol, int x)
- {
- if (arbol==NULL)
- {
- arbol = crearNodo(x);//Límite de la funcion
- }
- else if (x<arbol->nro)
- {
- insertar(arbol->izq, x);
- }
- else if (x>arbol->nro)
- {
- insertar(arbol->der, x);
- }
- }
- void imprimir(abb &arbol, int n);
- int main()
- {
- abb arbol = NULL; //Crear árbol
- int n, x, opcion;
- //Menú
- do
- {
- system("color 4F");
- system("cls");
- cout << "Menu\n\t1. Ingresar datos al árbol\n\t2. Ver árbol (Horizontal)\n\3. Salir" << endl;
- } while (true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement