#include using namespace std; char c; stack s; void mul(){ int a=s.top();s.pop(); int b=s.top();s.pop(); s.push(a*b); } void div(){ int a=s.top();s.pop(); int b=s.top();s.pop(); s.push(b/a); } void add(){ int a=s.top();s.pop(); int b=s.top();s.pop(); s.push(a+b); } void sub(){ int a=s.top();s.pop(); int b=s.top();s.pop(); s.push(b-a); } bool eq0(){ int a=s.top(); s.pop(); return a==0; } int main(){ s.push(0); label1: s.push(10); mul(); c=getchar(); s.push(c); s.push(s.top()); s.push(32); sub(); if(eq0()){ goto label2; } s.push(48); sub(); add(); goto label1; label2: s.pop(); s.push(10); div(); s.push(0); label3: s.push(10); mul(); c=getchar(); s.push(c); s.push(s.top()); s.push(10); sub(); if(eq0()){ goto label4; } s.push(48); sub(); add(); goto label3; label4: s.pop(); s.push(10); div(); add(); printf("%d",s.top()); s.pop(); s.push(32); printf("%c",s.top()); label5: c=getchar(); s.push(c); s.push(s.top()); s.push(10); sub(); if(eq0()){ goto label6; } printf("%c",s.top()); s.pop(); goto label5; label6: s.push(10); printf("%c",s.top()); s.pop(); }