結果

問題 No.256 桁の数字を入れ替え (2)
ユーザー NoNo
提出日時 2017-08-02 21:51:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 1,559 bytes
コンパイル時間 2,560 ms
コンパイル使用メモリ 106,240 KB
実行使用メモリ 20,108 KB
最終ジャッジ日時 2024-04-19 13:35:41
合計ジャッジ時間 3,124 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
17,664 KB
testcase_01 AC 21 ms
17,536 KB
testcase_02 AC 32 ms
19,976 KB
testcase_03 AC 33 ms
20,108 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.Text;

namespace y
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            int[] c = new int[10];

            foreach (var i in n)
            {
                switch (i)
                {
                    case '0':
                        c[0]++;
                        break;
                    case '1':
                        c[1]++;
                        break;
                    case '2':
                        c[2]++;
                        break;
                    case '3':
                        c[3]++;
                        break;
                    case '4':
                        c[4]++;
                        break;
                    case '5':
                        c[5]++;
                        break;
                    case '6':
                        c[6]++;
                        break;
                    case '7':
                        c[7]++;
                        break;
                    case '8':
                        c[8]++;
                        break;
                    case '9':
                        c[9]++;
                        break;
                }
            }

            var sb = new StringBuilder();
            for (int i = 9; i >= 0; i--)
            {
                for (int j = 0; j < c[i]; j++)
                {
                    sb.Append(i.ToString());
                }
            }

            Console.WriteLine(sb.ToString());
        }
    }
}
0