using namespace std; #include <iostream> #include "assignment.h" struct node_a { char var; bool value; assignment left; assignment right; }; void init(assignment & t) { t=NULL; } retval insert(assignment & t, char v, bool value) { if (t==NULL) { t = new node_a; if (t==NULL) return FAIL; t->var = v; t->value = value; t->left = NULL; t->right = NULL; return OK; } else if (v < t->var) return insert(t->left, v, value); else if (v > t->var) return insert(t->right, v, value); else return FAIL; } retval find (assignment t, char elem, bool &value) { if (t==NULL) return FAIL; else if(elem==t->var) { value=t->value; return OK; } else if (elem < t->var) return find(t->left,elem,value); else // (elem > t->var) return find(t->right,elem,value); } void print_assignment(assignment t) { if (t!=NULL) { print_assignment(t->left); cout << t->var << "=" << t->value << endl; print_assignment(t->right); } } assignment read_assignment(){ assignment a = NULL; char var; bool value; cin >> var; if (var!='{') return NULL; while(!cin.eof()){ cin >> var; if (var=='}') return a; cin >> value; retval r = insert(a,var,value); if (r==FAIL) return NULL; } return NULL; }