infix -> postfix 변환


infix -> postfix 변환

#include <iostream> using namespace std; void push(char num); char pop(int i); void polish(int i); char pri(char i); char satck[10]; int top = 0; int m; int n = 0; char infix[10] = { '(','1','+','2',')','*','3' }; char postfix[10]; void main() { for (int i = 0; i <= 6; i++) { if (infix[i] == '(') { push(infix[i]); } else if (infix[i] == ')') { while (satck[top - 1] != '(') { postfix[n++] = pop(i); } pop(i); } else if (pri(infix[i]) <= 2) { polish(i); push(infix[i]); } else { push(infix[i]); } } for (int k = top - 1; k >= 0; k--) postfix[n++] = pop(k); for (int i = 0; i <= n; ..........



원문링크 : infix -> postfix 변환