C/C++の宿題片付けます 124代目
■ このスレッドは過去ログ倉庫に格納されています
0272271
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());
}
■ このスレッドは過去ログ倉庫に格納されています