import java.util.Scanner;
public class 凯撒密码 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num=sc.nextInt();
String a = sc.next();
for (int i = 0; i < a.length(); i++) {
int b = (a.charAt(i) - 'a' + num) % 26+'a';//一个字符减去'a',是把这个字符变成相应的ASCII码
System.out.print((char) b);
}
}
}
Java实现 洛谷 P1914 小书童——凯撒密码
最新推荐文章于 2024-02-27 22:19:49 发布