結果

問題 No.289 数字を全て足そう
ユーザー gomagoma
提出日時 2017-09-19 21:31:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 154 ms / 1,000 ms
コード長 420 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 74,872 KB
実行使用メモリ 54,440 KB
最終ジャッジ日時 2024-04-25 18:18:48
合計ジャッジ時間 6,307 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
54,412 KB
testcase_01 AC 125 ms
53,892 KB
testcase_02 AC 125 ms
54,148 KB
testcase_03 AC 125 ms
54,020 KB
testcase_04 AC 124 ms
54,028 KB
testcase_05 AC 121 ms
52,848 KB
testcase_06 AC 127 ms
54,016 KB
testcase_07 AC 147 ms
54,060 KB
testcase_08 AC 152 ms
54,224 KB
testcase_09 AC 132 ms
54,440 KB
testcase_10 AC 126 ms
53,260 KB
testcase_11 AC 140 ms
54,084 KB
testcase_12 AC 145 ms
54,168 KB
testcase_13 AC 140 ms
54,036 KB
testcase_14 AC 143 ms
54,088 KB
testcase_15 AC 143 ms
54,332 KB
testcase_16 AC 128 ms
53,204 KB
testcase_17 AC 141 ms
54,308 KB
testcase_18 AC 145 ms
54,360 KB
testcase_19 AC 146 ms
53,888 KB
testcase_20 AC 141 ms
54,292 KB
testcase_21 AC 124 ms
53,920 KB
testcase_22 AC 143 ms
54,172 KB
testcase_23 AC 154 ms
54,176 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)));
			} else {
				continue;
			}
		}
		System.out.println(ans);

	}
}
0