java 凯撒密码_Java代码错误,凯撒密码程序。

import java.util.Scanner;

public class clq{

public static void main(String[]args){

Scanner in=new Scanner(System.in);

String words=in.nextLine();

char[] wordsList=new char[]{};

for(int i=0;i<=words.length();i++)

wordsList[i]=words.charAt(i);

System.out.println("Please type words,there should be less than 501 words.");//警告1

System.out.println("Please check contents,make sure there is no character which goes beyond 40-126(ASCII).The programme only supports English.");//警告2

lockwords(wordsList);//加密

for(int i=1;i<=5;i++)q

System.out.println();//空格

System.out.println(wordsList);

}

public static void lockwords(char[] words){

for(int i=0;i<=words.length;i++){

if(words[i]>=40&&words[i]<=122)

words[i]=(char)((int)words[i]+4);

else if(words[i]<=126)

words[i]=(char)((int)words[i]-4);

else{

System.out.println("Find a character goes beyond 40-126 of ASCII!!!Index:"+i);

System.exit(1);

}

}

}

dd128a79fbe70d1017ac9cd9edf28444.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值