📄 caesar.java
字号:
import java.io.*;
class Caesar
{
public static void main(String args [])
throws IOException
{
InputStreamReader reader1 = new InputStreamReader(System.in);
BufferedReader input1 = new BufferedReader(reader1);
System.out.print("请输入密钥key:" + " ");
String text = input1.readLine();
int key = new Integer(text).intValue();
InputStreamReader reader2 = new InputStreamReader(System.in);
BufferedReader input2 = new BufferedReader(reader2);
System.out.print("请输入明文:" + " ");
String data = input2.readLine();
String es="";
for (int i = 0; i < data.length(); i++)
{
char c = data.charAt(i);
if (c >= 'a' && c <= 'z')
{
c += key % 26;
if (c < 'a') c += 26;
if (c > 'z') c -= 26;
}
else if (c >= 'A' && c <= 'Z')
{
c += key % 26;
if (c < 'A') c += 26;
if (c > 'Z') c -= 26;
}
es += c;
}
System.out.print("产生的密文是:"+es);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -