結果

問題 No.289 数字を全て足そう
ユーザー kohaku_kohaku
提出日時 2016-11-12 20:09:19
言語 Java
(openjdk 23)
結果
AC  
実行時間 197 ms / 1,000 ms
コード長 557 bytes
コンパイル時間 2,418 ms
コンパイル使用メモリ 74,248 KB
実行使用メモリ 53,744 KB
最終ジャッジ日時 2024-11-25 21:33:40
合計ジャッジ時間 7,121 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String [] arr = S.split("");
        int sum = 0;
        for(int i=0; i<arr.length; i++){
            int temp = parseint(arr[i],0);
            sum += temp;
        }
        System.out.println(sum);
    }
    static int parseint(String a, int b){
        try{
            return Integer.parseInt(a);
        } catch ( NumberFormatException e ) {
            return b;
        }
    }
}
0