#13426: RE......


k034006 (Sine Wu)

學校 : 高雄市立高雄高級中學
編號 : 46921
來源 : [140.112.230.10]
最後登入時間 :
2024-04-08 03:46:24
d016. 後序運算法 | From: [180.217.125.162] | 發表日期 : 2018-02-17 20:18

以下是code

傳出去之後顯示"溢位或除以0的錯誤"

(我開long long應該不會溢位...)

 

#include<stdio.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string.h>
#include<memory.h>
#include<math.h>
#include<queue>
#define LL long long
#define ULL unsigned long
using namespace std;
int main(){
    int vs=0;
    vector<LL> v;
    string s;
    while(getline(cin,s)){
        v.clear();
        for(int i=0;s[i]!='\n'&&s[i]!='\0';i++){
            if(s[i]>='0'&&s[i]<='9'){
            LL n=0;
            for(;s[i]!=' ';i++){
                n=10*n+s[i]-'0';
            }
            v.push_back(n);
            vs++;
            }
            else if(s[i]=='+'){
            v[vs-2]+=v[vs-1];
            v.pop_back();
            vs--;
            }
            else if(s[i]=='-'){
            v[vs-2]-=v[vs-1];
            v.pop_back();
            vs--;
            }
            else if(s[i]=='*'){
            v[vs-2]*=v[vs-1];
            v.pop_back();
            vs--;
            }
            else if(s[i]=='/'){
            v[vs-2]/=v[vs-1];
            v.pop_back();
            vs--;
            }
            else if(s[i]=='%'){
            v[vs-2]%=v[vs-1];
            v.pop_back();
            vs--;
            }
            else continue;
        }
            printf("%lld\n",v[0]);
        }
        return 0;
}

 
ZeroJudge Forum