C/C++の宿題片付けます 124代目at TECH
C/C++の宿題片付けます 124代目 - 暇つぶし2ch271:デフォルトの名無しさん
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