Created
February 17, 2016 16:07
-
-
Save MirkoPani/45c79c10265324a332df to your computer and use it in GitHub Desktop.
[2016-02-16] Challenge #254 [Easy] Atbash Cipher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| int main() | |
| { | |
| std::string sentence; | |
| std::cout << "Insert a sentence to translate to Cipher: " << std::endl; | |
| std::getline(std::cin,sentence); | |
| for (char i : sentence) | |
| { | |
| if (i >= 'a' && i <= 'z') | |
| { | |
| std::cout << (char)('z' - i + 'a'); | |
| } | |
| else if (i >= 'A' && i <= 'Z') | |
| { | |
| std::cout << (char)('Z' - i + 'A'); | |
| } | |
| else | |
| std::cout << i; | |
| } | |
| std::cout << std::endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment