Skip to content

Instantly share code, notes, and snippets.

@MirkoPani
Created February 17, 2016 16:07
Show Gist options
  • Select an option

  • Save MirkoPani/45c79c10265324a332df to your computer and use it in GitHub Desktop.

Select an option

Save MirkoPani/45c79c10265324a332df to your computer and use it in GitHub Desktop.
[2016-02-16] Challenge #254 [Easy] Atbash Cipher
#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