結果

問題 No.708 (+ー)の式
ユーザー greentea011greentea011
提出日時 2018-10-18 16:13:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 22,528 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 07:05:15
合計ジャッジ時間 787 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 0 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main() {
    int ans=0;
    int tmp;
    int *tg = &ans;
    int next=1;
    int tb=1;
    char c;
    while((c=getchar()) != '\n') {
        switch (c) {
        case '+':
            next=1;
            break;
        case '-':
            next=-1;
            break;
        case '(':
            tb=next;
            next=1;
            tmp=0;
            tg=&tmp;
            break;
        case ')':
            ans+=(tmp*tb);
            tg=&ans;
            next=1;
            tb=1;
            break;
        default:
            (*tg)+=((c-'0')*next);
        }
    }
    printf("%d\n", ans);
    return 0;
}
0