結果

問題 No.289 数字を全て足そう
ユーザー len_discoreglen_discoreg
提出日時 2016-06-02 21:56:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 1,000 ms
コード長 652 bytes
コンパイル時間 4,202 ms
コンパイル使用メモリ 75,136 KB
実行使用メモリ 41,576 KB
最終ジャッジ日時 2024-04-16 23:20:47
合計ジャッジ時間 9,027 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
41,224 KB
testcase_01 AC 132 ms
41,000 KB
testcase_02 AC 135 ms
41,096 KB
testcase_03 AC 134 ms
41,416 KB
testcase_04 AC 130 ms
41,520 KB
testcase_05 AC 138 ms
41,364 KB
testcase_06 AC 135 ms
41,004 KB
testcase_07 AC 150 ms
41,396 KB
testcase_08 AC 153 ms
41,376 KB
testcase_09 AC 134 ms
41,200 KB
testcase_10 AC 150 ms
41,260 KB
testcase_11 AC 144 ms
41,128 KB
testcase_12 AC 149 ms
41,296 KB
testcase_13 AC 143 ms
41,296 KB
testcase_14 AC 148 ms
41,576 KB
testcase_15 AC 149 ms
41,304 KB
testcase_16 AC 144 ms
41,532 KB
testcase_17 AC 147 ms
41,184 KB
testcase_18 AC 145 ms
41,112 KB
testcase_19 AC 152 ms
41,216 KB
testcase_20 AC 152 ms
41,384 KB
testcase_21 AC 128 ms
41,432 KB
testcase_22 AC 145 ms
41,252 KB
testcase_23 AC 152 ms
41,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yuki289 {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		char[] beforeOmitCharArr = str.toCharArray();
		int total = 0;

		for(int i = 0; i < beforeOmitCharArr.length; i++){
			if(isNum((beforeOmitCharArr[i]))){
				total = total + Character.getNumericValue(beforeOmitCharArr[i]);
			}
		}

		System.out.println(total);
	}

	static boolean isNum(char ch) {
		if(ch == '0' || ch == '1' || ch == '2' || ch == '3' || ch == '4' || ch == '5'||
		   ch == '6' || ch == '7' || ch == '8' || ch == '9'){
			return true;
		}else{
			return false;
		}

	}
}
0