結果

問題 No.289 数字を全て足そう
ユーザー YamaKasa
提出日時 2018-04-19 16:00:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 219 ms / 1,000 ms
コード長 432 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 75,200 KB
実行使用メモリ 57,660 KB
最終ジャッジ日時 2024-06-27 04:48:45
合計ジャッジ時間 7,325 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		//System.out.println("半角英数字の文字列");
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		scanner.close();
		int sum = 0;
		for(int i = 0; i < str.length(); i++) {
			String s = str.substring(i,i+1);
			if(s.matches("[0-9]{1}")) {
				sum += Integer.parseInt(s);
			}
		}
		System.out.println(sum);
	}
}
0