I have this code:
#include <iostream>
#include <string>
#include “stack.h”
int main (int argc, char *argv[]) {
char *a = argv[1];
int N = strlen(a);
stack<int> polish(N); int el;
for (int i = 0; i < N; i++){
if (a[i] == '+'){
el = polish.readStack(); polish.outofStack();
polish.inStack( el + polish.readStack()); polish.outofStack()
}
if (a[i] == '*'){
el = polish.readStack(); polish.outofStack();
polish.inStack(el * polish.readStack()); polish.outofStack()
}
if ((a[i] >= '0') && (a[i] <= '9')){
el = polish.readStack(); polish.outofStack()
polish.inStack(10 * el + (a[i++]-'0'));
}
}
cout << polish.outofStack() << endl;
}
How does it work? And what does it mean this line?
polish.inStack(10 * el + (a[i++]-'0'));