結果

問題 No.163 cAPSlOCK
ユーザー Cecil
提出日時 2022-12-20 13:18:49
言語 Java
(openjdk 23)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 748 bytes
コンパイル時間 4,258 ms
コンパイル使用メモリ 76,812 KB
実行使用メモリ 54,408 KB
最終ジャッジ日時 2024-11-18 01:48:43
合計ジャッジ時間 7,469 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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