In a coding problem I've been working on for some time now, I've come to a step where I have to evaluate a mathematical expression that looks like this :
3 * 2 ^ 3 ^ 2 * 5
and should be evaluated like this :
3 * 2 ^ 3 ^ 2 * 5 = 3 * 2^(3 * 2) * 5 = 3 * 64 * 5 = 960.
In the current form of my implementation, I have two vectors, one contains the operands as integers, while the other one contains the operators as chars.
For the current case, they would be : vector<int> operands = { 3, 2, 3, 2, 5 }
and vector<char> operators = { '*', '^', '^', '*' }
.
This is just a sample case, the order of operations may differ in the sense that multiplication might not always be the first/last operation to be performed.
I've been stuck at this particular step for a while now, namely evaluating the expression encapsulated by the two vector containers to an integer. I've looked at some mathematical parsers I could find on the web, but I still don't see how to implement a proper evaluation.
A solution would be very much appreciated.