結果

問題 No.39 桁の数字を入れ替え
ユーザー merumeru_333333merumeru_333333
提出日時 2020-02-01 16:30:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 756 bytes
コンパイル時間 3,485 ms
コンパイル使用メモリ 106,720 KB
実行使用メモリ 23,900 KB
最終ジャッジ日時 2023-10-19 00:07:00
合計ジャッジ時間 5,278 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
23,900 KB
testcase_01 AC 24 ms
23,900 KB
testcase_02 AC 23 ms
23,900 KB
testcase_03 AC 23 ms
23,900 KB
testcase_04 AC 24 ms
23,900 KB
testcase_05 AC 23 ms
23,900 KB
testcase_06 AC 23 ms
23,900 KB
testcase_07 AC 23 ms
23,900 KB
testcase_08 AC 23 ms
23,896 KB
testcase_09 AC 23 ms
23,896 KB
testcase_10 AC 24 ms
23,900 KB
testcase_11 AC 24 ms
23,900 KB
testcase_12 AC 26 ms
23,900 KB
testcase_13 AC 23 ms
23,900 KB
testcase_14 AC 23 ms
23,900 KB
testcase_15 AC 23 ms
23,900 KB
testcase_16 AC 23 ms
23,900 KB
testcase_17 AC 23 ms
23,900 KB
testcase_18 AC 23 ms
23,900 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class test1
{
    static void Main()
    {
        var n = Console.ReadLine().ToCharArray();
        var length = n.Length;

        for (int i = 0; i < length; i++)
        {
            char x = n[i];
            int y = 0;
            for (int j = i; j < length; j++)
            {
                if (int.Parse(x.ToString()) <= int.Parse(n[j].ToString()))
                {
                    x = n[j];
                    y = j;
                }
            }
            if (x != n[i])
            {
                n[y] = n[i];
                n[i] = x;
                break;
            }
        }

        for (int i = 0; i < length; i++)
        {
            Console.Write(n[i]);
        }
        Console.WriteLine();
    }
}
0