結果

問題 No.289 数字を全て足そう
ユーザー 水野嶺水野嶺
提出日時 2020-05-25 10:59:01
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 704 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 74,956 KB
実行使用メモリ 43,704 KB
最終ジャッジ日時 2024-04-21 03:41:27
合計ジャッジ時間 6,476 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,276 KB
testcase_01 AC 103 ms
41,088 KB
testcase_02 AC 115 ms
41,056 KB
testcase_03 RE -
testcase_04 AC 112 ms
41,000 KB
testcase_05 AC 141 ms
43,704 KB
testcase_06 AC 145 ms
43,168 KB
testcase_07 AC 156 ms
42,700 KB
testcase_08 AC 151 ms
42,960 KB
testcase_09 AC 127 ms
41,568 KB
testcase_10 AC 145 ms
42,788 KB
testcase_11 AC 149 ms
42,796 KB
testcase_12 AC 158 ms
42,148 KB
testcase_13 AC 148 ms
42,856 KB
testcase_14 AC 156 ms
43,636 KB
testcase_15 AC 151 ms
42,724 KB
testcase_16 AC 145 ms
42,872 KB
testcase_17 AC 151 ms
42,560 KB
testcase_18 AC 163 ms
42,416 KB
testcase_19 AC 149 ms
42,832 KB
testcase_20 AC 147 ms
42,812 KB
testcase_21 AC 101 ms
39,904 KB
testcase_22 AC 157 ms
43,276 KB
testcase_23 AC 159 ms
42,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) 
	{
		// 入力値の読み込み
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int goukei = 0;
		
		// 数字以外を除去
		String intStr = s.replaceAll("[^0-9]", "");
		
		// 分割してアレイリストに格納
		String[] split = intStr.split("");
		
//		for(int i = 0;i < intStr.length;i++){
		
		//配列の要素をひとつづつfor文でまわす
		for (String str : split) {
			
			// 文字列から数字に変換
			int num = Integer.parseInt(str);
			
			//配列の要素を足していく
			goukei += num;
		}
		System.out.println(goukei);
//		}
	}
}
0