C/C++の宿題を片付けます 52代目
■ このスレッドは過去ログ倉庫に格納されています
0718デフォルトの名無しさん
2005/11/12(土) 00:08:47適当適当適当
#include<stdio.h>
#include<ctype.h>
int main(){
int c;
int st[80];
int*p=st;
while((c=getchar())!=EOF){
if(c=='\n')printf("%d\n",*--p),p=st;
else if(isspace(c))continue;
else if(isdigit(c))ungetc(c,stdin),scanf("%d",p++);
else if(c=='N')ungetc('-',stdin),scanf("%d",p++);
else if(c=='+')--p,p[-1]+=*p;
else if(c=='-')--p,p[-1]-=*p;
else if(c=='*')--p,p[-1]*=*p;
else if(c=='/')--p,p[-1]/=*p;
else if(c=='%')--p,p[-1]%=*p;
}
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています