結果

問題 No.289 数字を全て足そう
ユーザー len_proglen_prog
提出日時 2016-06-02 22:55:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 1,000 ms
コード長 677 bytes
コンパイル時間 3,840 ms
コンパイル使用メモリ 75,676 KB
実行使用メモリ 41,620 KB
最終ジャッジ日時 2024-04-16 23:24:13
合計ジャッジ時間 8,230 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
40,948 KB
testcase_01 AC 132 ms
41,268 KB
testcase_02 AC 127 ms
41,224 KB
testcase_03 AC 127 ms
41,284 KB
testcase_04 AC 127 ms
41,168 KB
testcase_05 AC 137 ms
41,376 KB
testcase_06 AC 137 ms
41,336 KB
testcase_07 AC 147 ms
41,516 KB
testcase_08 AC 151 ms
41,376 KB
testcase_09 AC 136 ms
41,468 KB
testcase_10 AC 145 ms
41,264 KB
testcase_11 AC 144 ms
41,316 KB
testcase_12 AC 151 ms
41,340 KB
testcase_13 AC 149 ms
41,532 KB
testcase_14 AC 148 ms
41,356 KB
testcase_15 AC 147 ms
41,052 KB
testcase_16 AC 139 ms
41,368 KB
testcase_17 AC 144 ms
41,152 KB
testcase_18 AC 146 ms
41,620 KB
testcase_19 AC 149 ms
41,328 KB
testcase_20 AC 147 ms
41,148 KB
testcase_21 AC 130 ms
41,552 KB
testcase_22 AC 144 ms
41,368 KB
testcase_23 AC 132 ms
40,344 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