結果

問題 No.289 数字を全て足そう
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-18 12:06:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 754 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 74,384 KB
実行使用メモリ 50,436 KB
最終ジャッジ日時 2024-04-25 15:25:16
合計ジャッジ時間 3,859 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,360 KB
testcase_01 AC 50 ms
50,072 KB
testcase_02 AC 51 ms
50,400 KB
testcase_03 AC 50 ms
50,344 KB
testcase_04 AC 50 ms
49,968 KB
testcase_05 AC 50 ms
49,952 KB
testcase_06 AC 52 ms
50,140 KB
testcase_07 AC 51 ms
50,148 KB
testcase_08 AC 51 ms
50,344 KB
testcase_09 AC 50 ms
50,436 KB
testcase_10 AC 51 ms
50,364 KB
testcase_11 AC 52 ms
50,348 KB
testcase_12 AC 52 ms
50,320 KB
testcase_13 AC 52 ms
50,360 KB
testcase_14 AC 57 ms
50,316 KB
testcase_15 AC 53 ms
50,068 KB
testcase_16 AC 55 ms
50,208 KB
testcase_17 AC 54 ms
50,376 KB
testcase_18 AC 54 ms
50,356 KB
testcase_19 AC 53 ms
50,428 KB
testcase_20 AC 52 ms
50,260 KB
testcase_21 AC 52 ms
50,420 KB
testcase_22 AC 55 ms
50,052 KB
testcase_23 AC 55 ms
50,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class No289 {
	public static void main(String[] args) throws IOException{
		
     	BufferedReader br = new BufferedReader((new InputStreamReader(System.in)));
	    char[] chr= br.readLine().toCharArray();  //toCharArray()はString型からchar型の配列にできる
     	
	    int sum = 0;
	    for (int i = 0; i< chr.length; i++){
	    	
	    	/*Character.isDigit(chr)でchrが数値かチェック*/
	    	
     		if (Character.isDigit(chr[i])){
     			
     			/*CharacterクラスのgetNumericVakue(char)でchar型をint型に変換*/
     			
     			sum += Character.getNumericValue(chr[i]); 
     		}
     	}
	    
	    System.out.println(sum);
	}
}
0