結果
| 問題 | 
                            No.49 算数の宿題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-02-06 19:26:46 | 
| 言語 | C90  (gcc 12.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 279 bytes | 
| コンパイル時間 | 279 ms | 
| コンパイル使用メモリ | 19,456 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-23 01:48:28 | 
| 合計ジャッジ時間 | 767 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
コンパイルメッセージ
main.c: In function ‘main’:
main.c:4:14: warning: implicit declaration of function ‘getchar’ [-Wimplicit-function-declaration]
    4 |     while((c=getchar())!=-1){
      |              ^~~~~~~
main.c:1:1: note: ‘getchar’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
  +++ |+#include <stdio.h>
    1 | 
main.c:13:5: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   13 |     printf("%d",!r?(m+s):(r<0?s:(m*s)));
      |     ^~~~~~
main.c:13:5: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:13:5: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
main.c:13:5: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
            
            ソースコード
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;
}