#include<stdio.h>
#define SIZE 10
double stack[SIZE];
int sp;
void push(double value);
double pop(void);
int isFull(void);
int isEmpty(void);
void answer(void);
void reset(void);
int main(void)
{
reset();
int resp;
double data;
while(1){
if(resp==9) break;
double x, y;
switch(resp){
case 1: x=pop();
y=pop();
push(y+x);
break;
case 2: x=pop();
y=pop();
push(y-x);
break;
case 3: x=pop();
y=pop();
push(y*x);
break;
case 4: x=pop();
y=pop();
push(y/x);
break;
case 5: scanf("%lf",&data
); push(data);
break;
}
}
answer();
return 0;
}
void push (double value){
if( isFull() ){
}
else{
stack[sp++] = value;
}
}
double pop(void){
if( isEmpty() ){
printf("スタックが空で取り出せませんでした/n"); return 0;
}
else{
return stack[--sp];
}
}
int isFull(void){
if(sp >= SIZE){
return 1;
}
else{
return 0;
}
}
int isEmpty(void){
if(sp<= 0){
return 1;
}
else{
return 0;
}
}
void answer(void){
printf("answer:%lf", stack
[0] ); }
void reset(void){
while(isEmpty()==0){
pop();}
}
I2luY2x1ZGU8c3RkaW8uaD4KCiNkZWZpbmUgU0laRSAxMApkb3VibGUgc3RhY2tbU0laRV07CmludCBzcDsKCgp2b2lkIHB1c2goZG91YmxlIHZhbHVlKTsKZG91YmxlIHBvcCh2b2lkKTsKaW50IGlzRnVsbCh2b2lkKTsKaW50IGlzRW1wdHkodm9pZCk7CnZvaWQgYW5zd2VyKHZvaWQpOwp2b2lkIHJlc2V0KHZvaWQpOwoKaW50IG1haW4odm9pZCkKewogICAgcmVzZXQoKTsKICAgIGludCByZXNwOwoJZG91YmxlIGRhdGE7CgoJd2hpbGUoMSl7CgkJc2NhbmYoIiVkIiwgJnJlc3ApOwoJCWlmKHJlc3A9PTkpIGJyZWFrOwoJCWRvdWJsZSB4LCB5OwoJCQoJCXN3aXRjaChyZXNwKXsKCQkJY2FzZSAxOiB4PXBvcCgpOwoJCQkJCXk9cG9wKCk7CgkJCQkJcHVzaCh5K3gpOwoJCQkJCWJyZWFrOwoJCQljYXNlIDI6IHg9cG9wKCk7C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