Skip to content

Instantly share code, notes, and snippets.

@maxchehab
Created October 3, 2017 00:38
Show Gist options
  • Save maxchehab/6e87d4dc8a498d6015ed297d246932d0 to your computer and use it in GitHub Desktop.
Save maxchehab/6e87d4dc8a498d6015ed297d246932d0 to your computer and use it in GitHub Desktop.
only works for capital letters. Look at an ascii table and modify if statement to make it work for lowercase.
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
char input[80];
int counter = 1;
string sInput;
int main()
{
cin >> sInput;
if(sInput.length() > 80){
cout << "Input is greater than 80 characters..." << endl;
return 0;
}
strcpy(input, sInput.c_str());
for(int i = 0; i < sInput.length(); i++){
if( input[i] >= 65 && input[i] <= 77){
input[i] += 13;
}else if(input[i] >= 78 && input[i] <= 90){
input[i] -= 13;
}
cout << input[i];
}
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment