結果

問題 No.784 「,(カンマ)」
ユーザー funakoshi
提出日時 2019-07-02 10:22:01
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 2,090 ms
コンパイル使用メモリ 103,480 KB
実行使用メモリ 17,152 KB
最終ジャッジ日時 2024-07-19 18:09:44
合計ジャッジ時間 2,961 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
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