結果

問題 No.18 うーさー暗号
ユーザー takutakutakutaku
提出日時 2020-09-16 14:12:42
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,332 bytes
コンパイル時間 2,641 ms
コンパイル使用メモリ 71,692 KB
実行使用メモリ 58,492 KB
最終ジャッジ日時 2023-09-04 03:28:07
合計ジャッジ時間 5,494 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main(String[] args) {
	    
	    // 入力値を取得
		Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        
        // 入力文字列を1文字ずつの配列にする
        // アルファベットの配列を準備する
        String[] s = str.split("",0);
        String[] alphabet = {"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"};
        String[] result = new String[s.length];
        
        for(int i = 0; i < s.length; i++) {
            
            for(int j = 0; j < alphabet.length; j++) {
                
                // アルファベットの配列と照合して要素番号を取得する
                if(s[i].equals(alphabet[j])) {
                    int n = j;
                    
                    // 要素番号をずらしたアルファベットを配列に格納する
                    if(n == 0) {
                        n = 25;
                    }else {
                        n--;
                    }
                    result[i] = alphabet[n];
                }
            }
        }
        
        // 出力する
        for(int i = 0; i < result.length; i++) {
            System.out.print(result[i]);
        }
	}
}
0