結果

問題 No.39 桁の数字を入れ替え
ユーザー AreTrashAreTrash
提出日時 2016-04-16 15:23:27
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 748 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 110,376 KB
実行使用メモリ 28,476 KB
最終ジャッジ日時 2024-04-15 02:10:59
合計ジャッジ時間 1,739 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 23 ms
26,432 KB
testcase_02 RE -
testcase_03 AC 27 ms
26,500 KB
testcase_04 AC 23 ms
26,428 KB
testcase_05 AC 24 ms
26,304 KB
testcase_06 AC 24 ms
26,628 KB
testcase_07 AC 23 ms
24,652 KB
testcase_08 AC 24 ms
26,180 KB
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 24 ms
24,336 KB
testcase_15 AC 24 ms
26,376 KB
testcase_16 AC 24 ms
26,248 KB
testcase_17 AC 23 ms
24,624 KB
testcase_18 AC 22 ms
24,128 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.Linq;

namespace No39_1{
    public class Program{
        public static void Main(string[] args){
            var n = Console.ReadLine().ToCharArray();
            var length = n.Length;
            var max = n.Max();
            var index = 0;

            foreach(var c in n){
                if(c == max){
                    index++;
                } else{
                    break;
                }
            }

            var tmp = n[index];
            for(var i = length - 1; i > index; i--){
                if(n[i] == max){
                    n[index] = n[i];
                    n[i] = tmp;
                    break;
                }
            }

            Console.WriteLine(n);
        }
    }
}
0