3 Star 0 Fork 0

CS-IMIS-23/20172319

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Caesar.java 856 Bytes
一键复制 编辑 原始数据 按行查看 历史
public class Caesar
{
public static void main(String args[]) throws Exception{
String s=args[0];
int key=Integer.parseInt(args[1]);
String es="";
for(int i=0;i<s.length( );i++)
{
char c=s.charAt(i);
if(c>='a' && c<='z') // 是小写字母
{ c+=key%26; //移动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.println(es);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/CS-IMIS-23/20172319.git
git@gitee.com:CS-IMIS-23/20172319.git
CS-IMIS-23
20172319
20172319
master

搜索帮助