macrofish

project ALG2

Apr 29th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int N=5;
  5.  
  6. struct uzel    
  7. {
  8.         bool value;
  9.         uzel *right;
  10.         uzel *left;
  11. };
  12.  
  13. class table                                                        
  14.   {
  15.    public:
  16.        table(const int N);
  17.        ~table();
  18.        void SetVariable (const int IndexOfVariable,const bool NewValue);  
  19.        bool GetVariableValue(const int IndexOfVariable);
  20.  
  21.    private:
  22.        bool *variables;  
  23.   };
  24.  
  25.   table::table(const int N)
  26.   {
  27.     variables=new bool[N];
  28.   }
  29.  
  30.   table::~table()
  31.   {
  32.     delete []variables;
  33.   }
  34.  
  35.   void table::SetVariable(const int IndexOfVariable, const bool NewValue)
  36.   {  
  37.     variables[IndexOfVariable]=NewValue;  
  38.   }
  39.  
  40.   bool table::GetVariableValue(const int IndexOfVariable)
  41.   {  
  42.       return variables[IndexOfVariable];
  43.   }
  44.  
  45.  
  46.  
  47.  
  48. class Node
  49. {
  50. public:
  51.     Node();
  52.     ~Node();
  53.     virtual bool Evaluate()=0;
  54.     void smazani(uzel * xRoot);
  55. private:
  56.     uzel * root;  
  57. };
  58.  
  59. Node::Node()
  60. {
  61.         root=NULL;
  62. }
  63. Node::~Node()
  64. {
  65.         smazani(root);
  66. }
  67. void Node::smazani(uzel *xRoot)
  68. {
  69.         if(xRoot!=NULL)
  70.         {
  71.                 smazani(xRoot->left);
  72.                 smazani(xRoot->right);
  73.                 delete xRoot;
  74.         }
  75. }
  76.  
  77. class insert : public Node
  78. {
  79. public:
  80.     insert();
  81.     ~insert();
  82.     void variable(table *variable_table, int IndexOfVariable);
  83. }
  84.  
  85. void insert::variable(table *variable_table, int IndexOfVariable)
  86. {
  87.  
  88. }
  89.  
  90. class And : public Node
  91. {
  92.  
  93. };
  94.  
  95. class Or : public Node
  96. {
  97.  
  98. };
  99.  
  100. class Xor : public Node
  101. {
  102.  
  103. };
  104.  
  105. class Not : public Node
  106. {
  107.  
  108. };
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. int main()
  120. {
  121.  
  122.     table variable_table(N);               
  123.     variable_table.SetVariable(0,1);   
  124.     variable_table.SetVariable(1, 1);  
  125.     variable_table.SetVariable(2, 0);  
  126.  
  127.     Node *root;
  128.  
  129.  
  130.  
  131.  
  132.     return 0;
  133. }
Advertisement
Add Comment
Please, Sign In to add comment