結果

問題 No.49 算数の宿題
ユーザー maimai
提出日時 2016-02-06 19:26:46
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 279 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 23,312 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 17:28:53
合計ジャッジ時間 836 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 0 ms
4,376 KB
testcase_09 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:4:14: warning: implicit declaration of function ‘getchar’ [-Wimplicit-function-declaration]
     while((c=getchar())!=-1){
              ^~~~~~~
main.c:4:14: note: ‘getchar’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
main.c:1:1:
+#include <stdio.h>
 
main.c:4:14:
     while((c=getchar())!=-1){
              ^~~~~~~
main.c:13:5: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
     printf("%d",!r?(m+s):(r<0?s:(m*s)));
     ^~~~~~
main.c:13:5: warning: incompatible implicit declaration of built-in function ‘printf’
main.c:13:5: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’

ソースコード

diff #

int main(){
    int s=0,r=-1,m=-1,c;
    while((c=getchar())!=-1){
        if ('0'<=c){
            s=s*10+c-'0';
        }else{
            m=!r?(m+s):(r<0?s:(m*s));
            r=c=='+';
            s=0;
        }
    }
    printf("%d",!r?(m+s):(r<0?s:(m*s)));
    return 0;
}
0