java-简单加密字母(小写后移两位,大写前移一位)
// 一句话加密(小写字母前推2,大写字母后推1)
public class Work16_3_14 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
StringBuffer str = new StringBuffer();
for (int i = 0; i < input.length(); i++) {
if (input.charAt(i)>='a' && input.charAt(i)<='z'){
// -2 % 26 = -2
char num = (char)((input.charAt(i)-'a'+26-2)%26+'a');
str.append(num);}
if (input.charAt(i)>='A' && input.charAt(i)<='Z'){
char a = (char)((input.charAt(i)-'A'+1)%26+'A');
str.append(a);
}
}
System.out.println(str);
}
}