diff --git a/hw2/hw2pr1/hw2pr1 b/hw2/hw2pr1/hw2pr1 new file mode 100755 index 0000000..fb7a60e Binary files /dev/null and b/hw2/hw2pr1/hw2pr1 differ diff --git a/hw2/hw2pr1/hw2pr1.cpp b/hw2/hw2pr1/hw2pr1.cpp new file mode 100644 index 0000000..7d44473 --- /dev/null +++ b/hw2/hw2pr1/hw2pr1.cpp @@ -0,0 +1,68 @@ +// Name: Alexander Huddleston UIN: 223000555 +// CSCE 420 +// Due: 11:59 P.M. Monday, October 30, 2017 +// hw2pr1.cpp + +#include +#include +#include +#include +#include "node.h" + +using namespace std; + +node makeTree(string input, node n, int level) +{ + char tempc = input[0]; + input = input.substr(1); + + if(tempc == '(') + { + } + + while(input.length() != 0) + { + if(tempc) + { + } + } +} + +int main(int argc, char **argv) +{ + // Initialization of input string. + string input = ""; + + // For testing, I want to read from a file. + // Typing in an tree from the keyboard each execution is a waste of time. + if(argc > 1) + { + if(!((string)argv[1]).substr(0, 2).compare("-f")) + { + ifstream file; + string line; + try + { + file.open("hw2pr1_data.txt"); + } + catch(exception e) + { + cerr << "File not found, or could not be opened." << endl; + } + while(!file.eof()) + { + getline(file, line); + input += line; + } + } + } + + else + { + cout << "Please input a tree: "; + cin >> input; + } + + cout << input << endl; + return 0; +} diff --git a/hw2/hw2pr1/hw2pr1_data.txt b/hw2/hw2pr1/hw2pr1_data.txt new file mode 100644 index 0000000..d96b905 --- /dev/null +++ b/hw2/hw2pr1/hw2pr1_data.txt @@ -0,0 +1 @@ +((3,12,8),(2,4,6),(14,5,2)) diff --git a/hw2/hw2pr1/makefile b/hw2/hw2pr1/makefile new file mode 100644 index 0000000..b1beddf --- /dev/null +++ b/hw2/hw2pr1/makefile @@ -0,0 +1,5 @@ +all: main.o +main.o: hw2pr1.cpp + g++ -std=c++17 hw2pr1.cpp -o hw2pr1 +clean: + rm -rf *.o hw2pr1 diff --git a/hw2/hw2pr1/node.h b/hw2/hw2pr1/node.h new file mode 100644 index 0000000..ca4fedf --- /dev/null +++ b/hw2/hw2pr1/node.h @@ -0,0 +1,25 @@ +#ifndef NODE_H +#define NODE_H + +#include + +using namespace std; + +class node +{ + private: + node* parent; + int level; + vector children; + public: + void setParent(node* p) { parent = p; }; + node* getParent() { return parent; }; + void setLevel(int l) { level = l; }; + int getLevel() { return level; }; + void setChildren(vector c) { children = c; }; + void addChild(node n) { children.push_back(n); }; + vector getChildren() { return children; }; + node getChildrenAt(int i) { return children.at(i); }; +}; + +#endif