Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void mathProcessor::compute(binaryTreeNode<string> *p){
- while (p != NULL) {
- compute(p->llink);
- compute(p->rlink);
- /* isOperator(p->info[0]);*/
- if((p->info[0]) != '+' && (p->info[0]) != '-' && (p->info[0]) != '*' && (p->info[0]) != '/'){
- theStack.push(p->info);
- }
- else {
- double num1;
- double num2;
- double num3;
- num1 = convertStringToDouble(theStack.top());
- theStack.pop();
- num2 = convertStringToDouble(theStack.top());
- theStack.pop();
- if((p->info[0]) == '+'){
- num3 = num1 + num2;
- theStack.push(convertDoubleToString(num3));
- }
- else if((p->info[0]) == '-'){
- num3 = num1 - num2;
- theStack.push(convertDoubleToString(num3));
- }
- else if((p->info[0]) == '*'){
- num3 = num1 * num2;
- theStack.push(convertDoubleToString(num3));
- }
- else {
- num3 = num1 / num2;
- theStack.push(convertDoubleToString(num3));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement