练习题:
凯撒密码:
import java.util.Scanner;
import java.io.*;
public class exp1
{
public static void main(String[] args)
{
System.out.printf("20155230 张瑞琦%n");
System.out.printf("凯撒密码:%n");
System.out.printf("请输入移位数字:%n");
Scanner scanner=new Scanner(System.in);
int i;
i=scanner.nextInt();
System.out.printf("请输入密文量%n");
int j;
j=scanner.nextInt();
int g;
for(g=0;g<j;g++)
{
System.out.printf("请输入密文%n");
char b='0';
int c;
try{
b=(char)new BufferedReader(new InputStreamReader(System.in)).read();
}catch(IOException ioe){
System.exit(0);
}
c=(int)b+i;
if(c>122)
c=c-26;
System.out.printf("%c%n", c);
}
}
}