結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
![]() |
提出日時 | 2020-02-01 16:30:42 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 25 ms / 5,000 ms |
コード長 | 756 bytes |
コンパイル時間 | 2,581 ms |
コンパイル使用メモリ | 106,704 KB |
実行使用メモリ | 17,792 KB |
最終ジャッジ日時 | 2024-09-18 20:05:39 |
合計ジャッジ時間 | 3,658 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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();}}