diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..6a17adbf5ab25731bee9032e41acf199e52e03f1 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +CC=g++ +LIB=./lib +INCLUDE=./include +SRC=./src +OBJ=./obj +LIBFLAGS = -lbst_lib +FLAGS = -Wall + +main: bst_lib + $(CC) $(SRC)/main.cpp $(FLAGS) -I$(INCLUDE) -L$(LIB) $(LIBFLAGS) -o bst + +bst_lib: + $(CC) -c $(SRC)/bst_lib.cpp $(FLAGS) -I$(INCLUDE) -o $(OBJ)/bst_lib.o + ar -cru $(LIB)/bst_lib.a $(OBJ)/bst_lib.o + +clean: + rm bst $(SRC)/*~ $(OBJ)/*o $(LIB)/*a diff --git a/include/bst_lib.h b/include/bst_lib.h new file mode 100644 index 0000000000000000000000000000000000000000..2aeccbac16eeb6b4e07261f7e2741529ec84c2dd --- /dev/null +++ b/include/bst_lib.h @@ -0,0 +1,19 @@ +// Implementado por Eduardo Machado +// 2015 + +class Node{ + private: + int key; + char truck; + Node *leftNode; + Node *rightNode; + Node *fatherNode; + + public: + void setKey(int newKey); + void setTruck(char newTruck); + void setLeftNode(Node *newLeftNode); + void setRightNode(Node *newRightNode); + void setFatherNode(Node *newRatherNode); + void printInOrder(); +}; diff --git a/src/bst_lib.cpp b/src/bst_lib.cpp index 0164a3317960e8e5c8fa49c46e21722339245428..43afaf97263e5288cc47508e493cc48b4ef63ef9 100644 --- a/src/bst_lib.cpp +++ b/src/bst_lib.cpp @@ -2,7 +2,7 @@ // 2015 #include <iostream> -#include "lib/bst_lib.h" +#include "bst_lib.h" using namespace std; @@ -29,7 +29,7 @@ void Node::setFatherNode(Node *newFatherNode){ void Node::printInOrder(){ if(this->leftNode!=NULL){ - this->leftNode.printInOrder() + this->leftNode->printInOrder() } std::cout << " " << this->truck << this->key << " " << std::endl; if(this->rightNode!=NULL){ diff --git a/src/main.cpp b/src/main.cpp index eeb0ff4e4594a530c85addfb6fab7fd460d633ef..83d683f6f6fa347fdad45df846c651ddc3f9b0e0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,7 @@ // 2015 #include <iostream> -#include "lib/bst_lib.h" +#include "bst_lib.h" using namespace std;