Professional Documents
Culture Documents
Lab Report 8
Lab Report 8
Lab Report: 8
#include <iostream>
#include <stack>
#include <string>
class Stack {
private:
std::stack<char> data;
public:
void push(char c) {
data.push(c);
}
char pop() {
char c = data.top();
data.pop();
return c;
}
char top() {
return data.top();
}
bool isEmpty() {
return data.empty();
}
int size() {
return data.size();
}
};
bool isOperator(char c) {
return (c == '+' || c == '-' || c == '*' || c == '/');
}
int main() {
std::string infix = "2+3*4";
std::string postfix = infixToPostfix(infix);
std::cout << "Infix: " << infix << std::endl;
std::cout << "Postfix: " << postfix << std::endl;
return 0;
}
Output:
Infix: 2+3*4
Postfix: 234*+
Ackermann(3, 4) = 125