C++ (The referencing style doesn't matter, idk why I had to fill that out) I was wondering if there was any way this code can be altered, maybe changing the if else statements to switch statements or...

1 answer below »
C++ (The referencing style doesn't matter, idk why I had to fill that out)
I was wondering if there was any way this code can be altered, maybe changing the if else statements to switch statements or anything else? I couldn't figure it out and I don't want to be flagged for my assignment for similarity.
#include #include #include
using namespace std;
int prec(char c){ if(c=='^'){ return 3; } else if(c=='/'||c=='*'){ return 2; } else if(c=='-'||c=='+'){ return 1; } else{ return -1; }}
void infToPostfix(string d) {

stack a; string result;

for (int i = 0; i char c = d[i]; if (c != ' ') { if ((c >= 'a' && c result += c; result+=" "; } else if (c == '(') { a.push('('); } else if (c == ')') { while (a.top() != '(') { result += a.top(); result+=" "; a.pop(); } a.pop(); } else { while (!a.empty() && prec(d[i]) result += a.top(); result+=" "; a.pop(); } a.push(c); } }



} while (!a.empty()) { result += a.top(); result+=" "; a.pop(); }

cout }














Answered Same DayApr 04, 2022

Answer To: C++ (The referencing style doesn't matter, idk why I had to fill that out) I was wondering if there...

Kshitij answered on Apr 04 2022
98 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here