結果
問題 | No.18 うーさー暗号 |
ユーザー |
![]() |
提出日時 | 2019-09-02 23:51:16 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 24 ms / 5,000 ms |
コード長 | 1,236 bytes |
コンパイル時間 | 991 ms |
コンパイル使用メモリ | 113,552 KB |
実行使用メモリ | 25,844 KB |
最終ジャッジ日時 | 2024-12-17 20:26:01 |
合計ジャッジ時間 | 1,934 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;namespace test9002{class Program{public static readonly int alphaCount = 26;public static readonly char[] alphas = new char[26] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };static void Main(){var arg = Console.ReadLine().Trim();char tempChar = 'a';int charOrder = 0;string outputWord = "";int reverseCount = 0;for (int i = 0; i < arg.Length; i++){tempChar = arg[i];charOrder = Array.IndexOf(alphas, tempChar);reverseCount = (i + 1) % alphaCount;if ((charOrder - reverseCount) >= 0){outputWord += alphas[charOrder - reverseCount];}else if ((charOrder - reverseCount) < 0){outputWord += alphas[charOrder - reverseCount + 26];}else{outputWord += tempChar;}}Console.WriteLine(outputWord);}}}