結果

問題 No.289 数字を全て足そう
ユーザー gomagoma
提出日時 2017-09-19 21:37:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 152 ms / 1,000 ms
コード長 393 bytes
コンパイル時間 1,874 ms
コンパイル使用メモリ 74,764 KB
実行使用メモリ 54,456 KB
最終ジャッジ日時 2024-04-25 18:19:05
合計ジャッジ時間 5,856 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
54,160 KB
testcase_01 AC 120 ms
54,084 KB
testcase_02 AC 117 ms
53,932 KB
testcase_03 AC 118 ms
54,120 KB
testcase_04 AC 119 ms
54,192 KB
testcase_05 AC 128 ms
54,144 KB
testcase_06 AC 123 ms
54,404 KB
testcase_07 AC 140 ms
54,260 KB
testcase_08 AC 138 ms
54,028 KB
testcase_09 AC 127 ms
53,900 KB
testcase_10 AC 152 ms
54,264 KB
testcase_11 AC 134 ms
54,056 KB
testcase_12 AC 144 ms
54,456 KB
testcase_13 AC 128 ms
54,076 KB
testcase_14 AC 122 ms
53,184 KB
testcase_15 AC 119 ms
53,228 KB
testcase_16 AC 139 ms
54,136 KB
testcase_17 AC 120 ms
52,896 KB
testcase_18 AC 122 ms
53,180 KB
testcase_19 AC 123 ms
53,644 KB
testcase_20 AC 138 ms
54,036 KB
testcase_21 AC 119 ms
54,240 KB
testcase_22 AC 124 ms
52,876 KB
testcase_23 AC 135 ms
53,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] array = str.toCharArray();
		int ans = 0;
		for (int i = 0; i < str.length(); i++) {
			if (array[i] >= '0' && array[i] <= '9') {
				ans += Integer.parseInt(String.valueOf(str.charAt(i)));
			}
		}
		System.out.println(ans);
	}
}
0