結果

問題 No.163 cAPSlOCK
ユーザー CecilCecil
提出日時 2022-12-20 13:18:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 748 bytes
コンパイル時間 2,540 ms
コンパイル使用メモリ 76,812 KB
実行使用メモリ 56,208 KB
最終ジャッジ日時 2024-04-29 02:47:10
合計ジャッジ時間 6,056 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
53,876 KB
testcase_01 AC 116 ms
54,020 KB
testcase_02 AC 96 ms
52,708 KB
testcase_03 AC 114 ms
53,096 KB
testcase_04 AC 127 ms
54,036 KB
testcase_05 AC 101 ms
52,964 KB
testcase_06 AC 115 ms
53,976 KB
testcase_07 AC 109 ms
52,968 KB
testcase_08 AC 121 ms
53,684 KB
testcase_09 AC 121 ms
54,400 KB
testcase_10 AC 117 ms
54,116 KB
testcase_11 AC 106 ms
52,988 KB
testcase_12 AC 108 ms
52,984 KB
testcase_13 AC 122 ms
54,004 KB
testcase_14 AC 114 ms
54,212 KB
testcase_15 AC 123 ms
54,072 KB
testcase_16 AC 124 ms
56,208 KB
testcase_17 AC 115 ms
53,740 KB
testcase_18 AC 107 ms
53,036 KB
testcase_19 AC 120 ms
54,016 KB
testcase_20 AC 116 ms
54,092 KB
testcase_21 AC 103 ms
52,916 KB
testcase_22 AC 124 ms
54,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		String str = scan.hasNextLine() ? scan.next():null;
		if (str == null) {
			System.out.println("入力エラー1");
			return;
		}
		
        
        // 半角アルファベット
        String regex_Alphabet = "^[A-Za-z]+$";
        
        
        if(!str.matches(regex_Alphabet)){
            System.out.println("入力エラー2");
            return;
        }
        
        
		for (int i = 0; i < str.length(); i++) {
			if (Character.isLowerCase(str.charAt(i))) {
					System.out.print((str.charAt(i)+"").toUpperCase());
			}else {
					System.out.print((str.charAt(i)+"").toLowerCase());
			}
		}
		

	}
}
0