Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- int encode(char*, char*);
- int main()
- {
- char str[1000];
- cin.getline(str, 999);
- char* res = new char[strlen(str)+1];
- encode(str, res);
- cout << res << endl;
- if (res != nullptr)
- {
- delete[] res;
- res = nullptr;
- }
- }
- int encode(char * src, char * res)
- {
- char * ptr = src;
- unsigned i = 0;
- while (*ptr != '\0') {
- if ((*ptr >= 'A' && *ptr <= 'Z') || (*ptr >= 'a' && *ptr <= 'z'))
- {
- if ((*ptr >= 'A' && *ptr < 'X') || (*ptr >= 'a' && *ptr < 'x'))
- {
- res[i++] = *ptr + 3;
- }
- else {
- res[i++] = *ptr - 23;
- }
- }
- else {
- res[i++] = *ptr;
- }
- ptr++;
- }
- res[i] = '\0';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement