- 272 名前:271 mailto:sage [2009/03/15(日) 18:00:01 ]
- 悪い。修正版。
#include<stdio.h> #include<ctype.h> int s[99],p; void push(int n){s[p++]=n;} int pop(void){return s[--p];} int main(){  int c,t;  for(;(c=getchar())!=EOF&&c!='\n';)   if(isspace(c));   else if(c=='+')t=pop(),push(pop()+t);   else if(c=='-')t=pop(),push(pop()-t);   else if(c=='*')t=pop(),push(pop()*t);   else if(c=='/')t=pop(),push(pop()/t);   else if(ungetc(c,stdin),scanf("%d",&t)==1)push(t);   else return fprintf(stderr,"Parse error!");  printf("%d\n",pop()); }
|

|