結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
![]() |
提出日時 | 2016-04-16 15:23:27 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 748 bytes |
コンパイル時間 | 876 ms |
コンパイル使用メモリ | 104,832 KB |
実行使用メモリ | 18,560 KB |
最終ジャッジ日時 | 2024-10-04 10:15:23 |
合計ジャッジ時間 | 1,877 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 WA * 4 RE * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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); } } }