diff --git a/lab1/coding.cc b/lab1/coding.cc index c06bb86..1b51ffd 100644 --- a/lab1/coding.cc +++ b/lab1/coding.cc @@ -1,14 +1,9 @@ #include unsigned char encode(unsigned char c) { - if ((c >= 'A' && c <= 'Z')) - return ((c - 'A' + 13) % 26) + 'A'; - else if ((c >= 'a' && c <= 'z')) - return ((c - 'a' + 13) % 26) + 'a'; - else - return c; // Non-alphabetic characters are unchanged + return ++c; } unsigned char decode(unsigned char c) { - return encode(c); // ROT13 encoding and decoding are the same + return --c; }