結果

問題 No.559 swapAB列
ユーザー NoNo
提出日時 2017-08-26 00:39:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 2,124 ms
コンパイル使用メモリ 101,088 KB
実行使用メモリ 22,608 KB
最終ジャッジ日時 2023-08-05 19:14:17
合計ジャッジ時間 3,250 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
22,532 KB
testcase_01 AC 52 ms
22,608 KB
testcase_02 AC 52 ms
22,496 KB
testcase_03 AC 52 ms
20,524 KB
testcase_04 AC 52 ms
20,600 KB
testcase_05 AC 51 ms
20,496 KB
testcase_06 AC 52 ms
20,488 KB
testcase_07 AC 51 ms
18,572 KB
testcase_08 AC 52 ms
20,560 KB
testcase_09 AC 51 ms
22,516 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace y
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] c = Console.ReadLine().ToCharArray();
            int cnt = 0;

            for (int i = 0; i < c.Length - 1; i++)
            {
                for (int j = c.Length - 1; j > i; j--)
                {
                    if (c[j] < c[j -1])
                    {
                        char w = c[j];
                        c[j] = c[j -1];
                        c[j - 1] = w;
                        cnt++;
                    }
                }
            }

            Console.WriteLine(cnt);
        }
    }
}
0