Professional Documents
Culture Documents
Program Infix Ke Post
Program Infix Ke Post
<iostream
>
#include <sstream>
#include <stack>
#include <limits>
#include <string>
using namespace std;
int priority(char a) {
int temp;
if (a == '^')
temp = 1;
else if (a == '*' || a == '/')
temp = 2;
else if (a == '+' || a == '-')
temp = 3;
return temp;
}
int main() {
string infix;
cout << "Masukan Infix : ";
getline(cin, infix);
stack<char> opr_stack;
stringstream postfix;
while (!opr_stack.empty()) {
postfix << opr_stack.top();
opr_stack.pop();
}
cin.ignore(numeric_limits<streamsize>::max(), '\n');
return 0;
}