結果

問題 No.222 引き算と足し算
ユーザー 👑 CleyL
提出日時 2020-03-03 13:29:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 71,380 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-13 22:25:30
合計ジャッジ時間 1,534 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stack>
using namespace std;
int main(){
    string s;cin>>s;
    stack<int> nya;
    int nw = 1;
    bool num = false;
    char ke = 'e';
    for(int i = 0; s.size() > i; i++){
        if(!num && s[i] == '+')continue;
        else if(!num && s[i] == '-')nw *= -1;
        else if(!num)nw *= s[i]-'0',num = true;
        else if('0' <= s[i] && s[i] <= '9')nw = nw*10+s[i]-'0';
        else{
            nya.push(nw);
            num = false;
            nw = 1;
            if(s[i] == '+')ke = '-';
            else ke = '+';
        }
    }
    cout << nya.top()+(ke=='+'?nw:-nw) << endl;
}
0