結果

問題 No.289 数字を全て足そう
ユーザー nanatutmcnanatutmc
提出日時 2019-09-13 00:45:21
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 294 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 28,928 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-02 17:19:58
合計ジャッジ時間 1,012 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
    3 | main() {
      | ^~~~

ソースコード

diff #

#include <stdio.h>

main() {
    char str[100000];
    long sum = 0;
    
    scanf("%s", str);
    
    for (int i=0; i<100000; i++) {
        if (str[i] == 0)
            break;
        if (str[i] >= '0' && str[i] <= '9')
            sum += str[i] - '0';
    }
    
    printf("%d\n", sum);
}
0