亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Java的凱撒密碼解密程序,出現邏輯錯誤。

Java的凱撒密碼解密程序,出現邏輯錯誤。

化糖 2016-07-28 14:23:55
以下代碼似乎會讓IDE將回車看做字符,怎么回事? package?caesarCipher; import?java.util.Scanner; public?class?unlock?{ public?static?void?main(String[]args){ Scanner?in=new?Scanner(System.in); System.out.println("Please?type?words,there?should?be?less?than?2001.");//警告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 String?words=in.nextLine(); words.replace('\r','?'); char[]?wordsList=new?char[2000]; for(int?i=0;i<words.length();i++) wordsList[i]=words.charAt(i); unlock(wordsList);//解密 for(int?i=0;i<words.length();i++) System.out.print(wordsList[i]); System.out.println(); } public?static?void?unlock(char[]?words){ for(int?i=0;i<words.length;i++){ if(words[i]>=33){ words[i]=(char)(words[i]+219); } else?if(i>=37&&i<=255){ words[i]=(char)(words[i]-4); } else{ System.out.println("\nFind?a?character?goes?beyond?33-255?of?ASCII!!!Index:"+i); System.exit(1); } } } }
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1663 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號