As Solution 1 mentioned, you've already been told what the problem is.
Please do not repost questions. It is considered inappropriate to such a degree that a repost is subject to being closed.
You need to debug your code to find out why it overflows the stack. No one is going to debug it for you. They wouldn't be doing you a favor anyway, because debugging is an indispensable skill that you need to learn. Trying to debug code by studying it, or executing it with pencil and paper, is error prone and extremely inefficient for all but the simplest programs.
Since you're writing C++, I have some suggestions.
1. Get rid of the
#define
statements, which are rarely appropriate in C++. The first one can be replaced with
const double M_PI = 3.14159265358979323846;
The others are just abbreviations, so spell them out in full. In a large program that uses external interfaces, no one will want to have to remember your custom abbreviations to read your code.
2. Don't check a
bool
by comparing it to
0
,
1
,
false
, or
true
. It makes the code look like it was written by a newbie. Curiously, the code only does this in some places but not others.
if(autrege(test) == true)...
while(presedence.empty() == 1 && oprators.empty() == 1)...
if(autrege(test))...
while(!presedence.empty() && !oprators.empty())...
3. Format your code by indenting code within braces, putting each statement on its own line, adding a space before and after binary operators, and using a consistent style. This will make your code much easier to read. The first thing I do, when I need to study poorly formatted code, is to reformat it.
while(presedence.empty() != 1 && oprators.empty() != 1){output.push(oprators.top());
oprators.pop();presedence.pop();}
while(!output.empty()){cout<<output.front()<<", ";output.pop();}
while(!presedence.empty() && !oprators.empty()) {
output.push(oprators.top());
oprators.pop();
presedence.pop();
}
while(!output.empty()) {
cout << output.front() << ", ";
output.pop();
}
Being consistent means things like
- Does a
{
go at the end of the line or on its own line?
- Is code indented a multiple of 3, 4, or 8 spaces?
- Is there a space between a keyword and a
(
that follows?