結果

問題 No.784 「,(カンマ)」
ユーザー funakoshifunakoshi
提出日時 2019-07-02 10:22:01
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 4,783 ms
コンパイル使用メモリ 101,504 KB
実行使用メモリ 22,624 KB
最終ジャッジ日時 2023-09-27 00:30:32
合計ジャッジ時間 6,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
20,420 KB
testcase_01 AC 49 ms
20,564 KB
testcase_02 AC 48 ms
20,452 KB
testcase_03 AC 51 ms
22,584 KB
testcase_04 AC 49 ms
20,476 KB
testcase_05 AC 50 ms
20,548 KB
testcase_06 AC 50 ms
20,420 KB
testcase_07 AC 49 ms
20,576 KB
testcase_08 AC 51 ms
22,624 KB
testcase_09 AC 49 ms
20,440 KB
testcase_10 AC 50 ms
18,500 KB
testcase_11 AC 51 ms
20,400 KB
testcase_12 AC 50 ms
20,488 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;
using System.Text;
using System.Threading.Tasks;

namespace yukicoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string num = Console.ReadLine();
            string[] cut = new string[num.Length];
            string str = "";
            if(num.Length%3==2)
            {
                cut[0] = num.Substring(0, 2);
                num = num.Remove(0, 2);
            }
            else if(num.Length%3==1)
            {
                cut[0] = num.Substring(0, 1);
                num = num.Remove(0, 1);
            }
            else
            {
                cut[0] = num.Substring(0,3);
                num = num.Remove(0, 3);
            }
            for (int i=1;i<num.Length-1;i+=3)
            {
                cut[i] = num.Substring(i-1, 3);
            }
            for(int i=0;i<cut.Length;i++)
            {
                
                if (!string.IsNullOrEmpty(cut[i]))
                {
                    str = str + cut[i] + ",";
                }
            }
            str=str.Remove(str.Length - 1, 1);
            Console.WriteLine(str);
        }
    }
}
0