20155230 《Java程序设计》实验一(Java开发环境的熟悉) 实验报告

练习题:

凯撒密码:

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);
		}
	}
}
原文地址:https://www.cnblogs.com/J1n233/p/6703597.html