結果

問題 No.289 数字を全て足そう
ユーザー jonki324jonki324
提出日時 2018-06-03 16:29:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 451 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 71,536 KB
実行使用メモリ 56,236 KB
最終ジャッジ日時 2023-09-12 21:55:11
合計ジャッジ時間 6,422 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,472 KB
testcase_01 AC 118 ms
55,380 KB
testcase_02 AC 118 ms
55,592 KB
testcase_03 AC 118 ms
55,340 KB
testcase_04 AC 120 ms
55,880 KB
testcase_05 AC 128 ms
55,932 KB
testcase_06 AC 125 ms
55,684 KB
testcase_07 AC 135 ms
55,776 KB
testcase_08 AC 134 ms
55,592 KB
testcase_09 AC 122 ms
55,912 KB
testcase_10 AC 131 ms
55,272 KB
testcase_11 AC 133 ms
55,484 KB
testcase_12 AC 135 ms
55,644 KB
testcase_13 AC 132 ms
56,236 KB
testcase_14 AC 135 ms
55,960 KB
testcase_15 AC 135 ms
55,848 KB
testcase_16 AC 131 ms
55,688 KB
testcase_17 AC 134 ms
55,816 KB
testcase_18 AC 136 ms
55,912 KB
testcase_19 AC 132 ms
56,008 KB
testcase_20 AC 134 ms
55,900 KB
testcase_21 AC 116 ms
56,220 KB
testcase_22 AC 134 ms
55,936 KB
testcase_23 AC 137 ms
55,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        char[] c = s.toCharArray();
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
            if (Character.isDigit(c[i])) {
                sum += Character.getNumericValue(c[i]);
            }
        }
        System.out.println(sum);
        scan.close();
    }
}
0