#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();
while(1){
int resp,sum;
double data,cal1,cal2;
if(resp == 9) break;
switch(resp){
case 1:cal1 = pop(); cal2 = pop();
printf("data:%lf\ndata:%lf\n",cal2
,cal1
); sum = cal2 + cal1;
push(sum);
break;
case 2:cal1 =pop(); cal2 = pop();
printf("data:%lf\ndata:%lf\n",cal2
,cal1
); sum = cal2 - cal1;
push(sum);
break;
case 3:cal1 =pop(); cal2 = pop();
printf("data:%lf\ndata:%lf\n",cal2
,cal1
); sum = cal2 * cal1;
push(sum);
break;
case 4:cal1 =pop(); cal2 = pop();
printf("data:%lf\ndata:%lf\n",cal2
,cal1
); sum = cal2 / cal1;
push(sum);
break;
case 5:scanf("%lf",&data
); push(data);
break;
}
}
answer();
return 0;
}
void push(double value){
if( isFull() ){
}
stack[sp++] = value;
}
double pop(void){
if( isEmpty() ){
printf("スタックが空で取り出せませんでした\n"); }
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){
}
void reset(void){
sp = 0;
for(int i=0;i<10;i++)
stack[i] = 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KCiNkZWZpbmUgU0laRSAxMApkb3VibGUgc3RhY2tbU0laRV07CmludCBzcDsKCnZvaWQgcHVzaChkb3VibGUgdmFsdWUpOwpkb3VibGUgcG9wKHZvaWQpOwppbnQgaXNGdWxsKHZvaWQpOwppbnQgaXNFbXB0eSh2b2lkKTsKdm9pZCBhbnN3ZXIodm9pZCk7CnZvaWQgcmVzZXQodm9pZCk7CgppbnQgbWFpbih2b2lkKXsKICAgIHJlc2V0KCk7CiAgICAKICAgIHdoaWxlKDEpewogICAgICAgIGludCByZXNwLHN1bTsKICAgICAgICBkb3VibGUgZGF0YSxjYWwxLGNhbDI7CiAgICAgICAgc2NhbmYoIiVkIiwmcmVzcCk7CgogICAgICAgIGlmKHJlc3AgPT0gOSkgICAgYnJlYWs7CgogICAgICAgIHN3aXRjaChyZXNwKXsKICAgICAgICAgICAgY2FzZSAxOmNhbDEgPSBwb3AoKTsgY2FsMiA9IHBvcCgpOwogICAgICAgICAgICAgICAgICAgcHJpbnRmKCJkYXRhOiVsZlxuZGF0YTolbGZcbiIsY2FsMixjYWwxKTsKICAgICAgICAgICAgICAgICAgIHN1bSA9IGNhbDIgKyBjYWwxOwogICAgICAgICAgICAgICAgICAgcHVzaChzdW0pOwogICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMjpjYWwxID1wb3AoKTsgY2FsMiA9IHBvcCgpOwogICAgICAgICAgICAgICAgICAgcHJpbnRmKCJkYXRhOiVsZlxuZGF0YTolbGZcbiIsY2FsMixjYWwxKTsKICAgICAgICAgICAgICAgICAgIHN1bSA9IGNhbDIgLSBjYWwxOwogICAgICAgICAgICAgICAgICAgcHVzaChzdW0pOwogICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMzpjYWwxID1wb3AoKTsgY2FsMiA9IHBvcCgpOwogICAgICAgICAgICAgICAgICAgcHJpbnRmKCJkYXRhOiVsZlxuZGF0YTolbGZcbiIsY2FsMixjYWwxKTsKICAgICAgICAgICAgICAgICAgIHN1bSA9IGNhbDIgKiBjYWwxOwogICAgICAgICAgICAgICAgICAgcHVzaChzdW0pOwogICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgNDpjYWwxID1wb3AoKTsgY2FsMiA9IHBvcCgpOwogICAgICAgICAgICAgICAgICAgcHJpbnRmKCJkYXRhOiVsZlxuZGF0YTolbGZcbiIsY2FsMixjYWwxKTsKICAgICAgICAgICAgICAgICAgIHN1bSA9IGNhbDIgLyBjYWwxOwogICAgICAgICAgICAgICAgICAgcHVzaChzdW0pOwogICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgNTpzY2FuZigiJWxmIiwmZGF0YSk7CiAgICAgICAgICAgICAgICAgICBwdXNoKGRhdGEpOwogICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9ICAgCiAgICB9CiAgICAKICAgIGFuc3dlcigpOwoKICAgIHJldHVybiAwOwp9Cgp2b2lkIHB1c2goZG91YmxlIHZhbHVlKXsKICAgIGlmKCBpc0Z1bGwoKSApewogICAgICAgIHByaW50Zigi44K544K/44OD44Kv44GM5rqA5p2v44Gn5YWl44KK44G+44Gb44KT44Gn44GX44GfXG4iKTsKICAgIH0KICAgIHN0YWNrW3NwKytdID0gdmFsdWU7Cn0KCmRvdWJsZSBwb3Aodm9pZCl7CiAgICBpZiggaXNFbXB0eSgpICl7CiAgICAgICAgcHJpbnRmKCLjgrnjgr/jg4Pjgq/jgYznqbrjgaflj5bjgorlh7rjgZvjgb7jgZvjgpPjgafjgZfjgZ9cbiIpOwogICAgfQogICAgcmV0dXJuIHN0YWNrWy0tc3BdOwp9CgppbnQgaXNGdWxsKHZvaWQpewogICAgaWYoc3AgPj0gU0laRSl7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICBlbHNlewogICAgICAgIHJldHVybiAwOwogICAgfQp9CgppbnQgaXNFbXB0eSh2b2lkKXsKICAgIGlmKHNwIDw9IDApewogICAgICAgIHJldHVybiAxOwogICAgfQogICAgZWxzZXsKICAgICAgICByZXR1cm4gMDsKICAgIH0KfQoKdm9pZCBhbnN3ZXIodm9pZCl7CiAgICBwcmludGYoImFuc3dlcjolbGYiLHBvcCgpKTsKfQoKdm9pZCByZXNldCh2b2lkKXsKICAgIHNwID0gMDsKICAgIGZvcihpbnQgaT0wO2k8MTA7aSsrKQogICAgc3RhY2tbaV0gPSAwOwp9