C/C++の宿題片付けます 124代目 at TECH
[2ch|▼Menu]
271:デフォルトの名無しさん
09/03/15 17:57:16
>>248 parseあんま自信無いw
#include<stdio.h>
#include<ctype.h>
int s[99],p,a;
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());
}


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5289日前に更新/131 KB
担当:undef