Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d1a81b

Browse files
authored
Merge pull requestTheAlgorithms#732 from markettes/patch-1
Efficiency
2 parents8f60321 +ed99f58 commit8d1a81b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎ciphers/Caesar.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public class Caesar {
2424
publicstaticStringencode(Stringmessage,intshift) {
2525
Stringencoded ="";
2626

27-
while (shift >=26) {// 26 = number of latin letters
28-
shift-=26;
29-
}
27+
28+
shift%=26;
29+
3030

3131
finalintlength =message.length();
3232
for (inti =0;i <length;i++) {
@@ -62,9 +62,9 @@ public static String encode(String message, int shift) {
6262
publicstaticStringdecode(StringencryptedMessage,intshift) {
6363
Stringdecoded ="";
6464

65-
while (shift >=26) {// 26 = number of latin letters
66-
shift-=26;
67-
}
65+
66+
shift%=26;
67+
6868

6969
finalintlength =encryptedMessage.length();
7070
for (inti =0;i <length;i++) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp