Home > Back-end >  The great god, C, won't solve the problem.
The great god, C, won't solve the problem.

Time:09-22

The suffix binary tree:
This is a mistake:
| |===Build: Debug in postfix calculator (compiler: the GNU GCC compiler)===|
Obj \ Debug \ postfixcounter o | | In the function ` ZN7postfix10importtreeEv ': |
E: \ \ postfix calculator \ postfixcounter codeblocks experiment CPP | 139 | undefined reference to ` postfix: : newtree (char) '|
E: \ \ postfix calculator \ postfixcounter codeblocks experiment CPP | 143 | undefined reference to ` postfix: : newtree (char) '|
E: \ \ postfix calculator \ postfixcounter codeblocks experiment CPP | 147 | undefined reference to ` postfix: : newtree (char) '|
E: \ \ postfix calculator \ postfixcounter codeblocks experiment CPP | 164 | undefined reference to ` postfix: : newtree (char) '|
E: \ \ postfix calculator \ postfixcounter codeblocks experiment CPP | 169 | undefined reference to ` postfix: : newtree (char) '|
Obj \ Debug \ postfixcounter. O: E: \ \ codeblocks experiment postfix calculator \ postfixcounter CPP | 173 | more undefined references to ` postfix: : newtree (char) 'follow |
| |===the Build failed: 6 error (s), and 0 warning (s) (0 minute (s), 2 second (s))===|

This is the source file:
The header file:
# # ifndef POSTFIXCOUNTER_H_INCLUDED
# define POSTFIXCOUNTER_H_INCLUDED
# include
using namespace std;
Struct nodeType
{
NodeType * left;
NodeType * right;
Char symbol;
int number;
};
The class postfix
{
Public:
Postfix ();
Postfix (const postfix&);
~ postfix ();
Void the locate ();
Void logicRule ();
NodeType * newtree (char);
Void importtree ();
Int backlargeNumber ();
Int addressing (int);
Int the output ();
Void subtraction (nodeType *);
Void the add (nodeType *);
Void multiply (nodeType *);
Void distraction (nodeType *);
Private:
Int a [20] [2].
Int b [20];
Bool c [20];
Int largeNumber;
NodeType * mycounterarray [20];
NodeType * head;
NodeType * current;
NodeType * trailcurrent;
String mycounter;
Const char * first;
Int maxsize;
int length;
};

# endif//POSTFIXCOUNTER_H_INCLUDED
This is the class definition:
# include
# include
# include "postfixcounter. H"
using namespace std;

Postfix: : postfix ()
{
cout<" Both please input your postfix counter: ";
Cin> Mycounter;
The head=mycounterarray [0];
The first=mycounter. C_str ();
Maxsize=length=mycounter. Length ();
LargeNumber=0;
B [20]=0;
C [20]=0;
}

Postfix: : postfix (const postfix& Other)
{
This - & gt; Mycounter=other. Mycounter;
The first=this - & gt; Mycounter. C_str ();
Length=maxsize=this - & gt; Mycounter. Length ();
LargeNumber=0;
}

Void postfix: : locate ()
{
A [0] [1]=1;
A [0] [0]=length + 1;
LargeNumber=1;
for(int i=0; i<=length; I++)
{
If the first [I]=='(')
{
A [largeNumber] [1]=I;
LargeNumber++;
}
If (first [I]==') ')
{
For (int k=19; K>=0; K -)
{
If (a [k] [1]!=0 & amp; & A [k] [0]==0)
{
A [k] [0]=I;
break;
}
}
}
}
}

Void postfix: : logicRule ()
{
For (int I=largeNumber - 1; I>=0; I -)
{
If (a [I] [1] & gt; A [I - 1] [1])
{
If (a [I] [0] {
B [I]=largeNumber;
C [I]=false;
}
If (a [I] [0] & gt; A [I - 1] [0])
{
[I]=largeNumber - 1 b;
C [I]=false;
}
}
LargeNumber of;
If (I==0)
{
B [0]=1;
}
}
}

NodeType * newtree (char temp)
{
NodeType * temp2;
The switch (temp)
{
Case (' + ') :
{
Temp2=new nodeType;
Temp2 - & gt;='+' symbol.
break;
}
Case (' - ') :
{
Temp2=new nodeType;
Temp2 - & gt;='-' symbol.
break;
}
Case (' * ') :
{
Temp2=new nodeType;
Temp2 - & gt;='*' symbol.
break;
}
Case ('/') :
{
Temp2=new nodeType;
Temp2 - & gt; Symbol='/';
break;
}
Case (') ') :
{
break;
}
Case (' (') :
{
break;
}
Default:
{
Temp2=new nodeType;
Temp2 - & gt; Number=int (temp) - 48;
break;
}
}
Return temp2;
}

Void postfix: : importtree ()
{
Thefirst nodeType *;
Int temp.
For (int k=backlargeNumber () - 1; K>=0; K -)
{
Int start=a, [k] [0] 1.
Int last=a [k] [1] + 1;
If ((start - the last)==2)
{
For (int I=start; I>=last; I -)
{
Char cash=first [I];
If (I==start)
{
The current=newtree (cash);
}
If (I==start - 1)
{
Current - & gt; Right=newtree (cash);
}
If (I==last)
{
Current - & gt; Left=newtree (cash);
}
}
Mycounterarray [k]=current;
}
The else
{
If ((start - the last) & gt; 2)
{
Int g=0;
For (int I=start; I>=last; I -)
{
Char cash=first [I];
If (first [I]! )
=') '{
If (g==0)
{
The current=newtree (cash);
Thefirst=current;
}
If (g==1)
{
Current - & gt; Right=newtree (cash);
}
If (g==2)
{
Current - & gt; Left=newtree (cash);
}
If (g==3)
{
The current=current - & gt; The left;
G=1;
Current - & gt; Right=newtree (cash);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull