結果

問題 No.289 数字を全て足そう
ユーザー k-a-rgbk-a-rgb
提出日時 2023-09-20 11:46:18
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 803 bytes
コンパイル時間 2,977 ms
コンパイル使用メモリ 102,696 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2023-09-20 11:46:24
合計ジャッジ時間 5,249 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,692 KB
testcase_01 AC 54 ms
18,688 KB
testcase_02 AC 57 ms
22,620 KB
testcase_03 AC 55 ms
20,744 KB
testcase_04 AC 55 ms
20,700 KB
testcase_05 AC 56 ms
20,676 KB
testcase_06 AC 56 ms
20,576 KB
testcase_07 AC 56 ms
20,728 KB
testcase_08 AC 57 ms
20,680 KB
testcase_09 AC 56 ms
20,772 KB
testcase_10 AC 56 ms
20,672 KB
testcase_11 AC 56 ms
20,664 KB
testcase_12 AC 57 ms
20,584 KB
testcase_13 AC 56 ms
20,712 KB
testcase_14 AC 57 ms
22,640 KB
testcase_15 AC 56 ms
20,612 KB
testcase_16 AC 56 ms
20,640 KB
testcase_17 AC 57 ms
20,704 KB
testcase_18 AC 57 ms
22,628 KB
testcase_19 AC 57 ms
20,740 KB
testcase_20 AC 57 ms
22,668 KB
testcase_21 AC 55 ms
20,688 KB
testcase_22 AC 57 ms
22,784 KB
testcase_23 AC 57 ms
20,776 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace PracticeAtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
			
			
			//足し算
			string sC = Console.ReadLine();
			string sCA = "";
			int number;
			int sumA = 0;
			//文字長さまで繰り返し処理
			//sC[i]だとchar型と扱われ、型の違いでError Foreach を用いて対策など
			for(int i = 0; i<sC.Length;i++){
				sCA =sC[i]+"";
				bool success = int.TryParse(sCA , out number);
				
				if(success){
					 //Console.WriteLine($"Converted'{sCA}'to {number},");
					 sumA = sumA +number;
				}else{
					sCA =sC[i]+"";
					//Console.WriteLine($"Attempted conversion of '{sCA ?? "<null>"}' failed.");
				}
			}
			Console.WriteLine(sumA);
				
			
		}
    }
}
0