Skip to content

Instantly share code, notes, and snippets.

@yuuki
Created May 25, 2012 00:15
Show Gist options
  • Save yuuki/2785033 to your computer and use it in GitHub Desktop.
Save yuuki/2785033 to your computer and use it in GitHub Desktop.
SRM Div2-147 250score
#include <string>
using namespace std;
class CCipher
{
public:
string decode(string cipherText, int shift)
{
for (int i = 0; i < cipherText.size(); ++i) {
if (cipherText[i] - shift < 'A') {
cipherText[i] = 'Z' + cipherText[i] - shift - 'A' + 1;
} else {
cipherText[i] -= shift;
}
}
return cipherText;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment