#include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> char *encode(char *e, int len); char *decode(char *d, int len); int main() { char toEncode[1001]; char toDecode[1001]; scanf("%s", toEncode); scanf("%s", toDecode); int lenE = strlen(toEncode); int lenD = strlen(toDecode); char *encoded = (char *)malloc((lenE + 1) * sizeof(char)); char *decoded = (char *)malloc((lenD + 1) * sizeof(char)); strcpy(encoded, encode(toEncode, lenE)); strcpy(decoded, decode(toDecode, lenD)); printf("%s\n", encoded); printf("%s\n", decoded); } char *encode(char *e, int len) { for(int i = 0; i < len; i++) { if(e[i] == 'Z') e[i] = 'a'; else if(e[i] == 'z') e[i] = 'A'; else if(e[i] == '9') e[i] = '0'; else if(isupper(e[i])) e[i] = tolower(e[i]) + 1; else if(islower(e[i])) e[i] = toupper(e[i]) + 1; else e[i]++; } return e; } char *decode(char *d, int len) { for(int i = 0; i < len; i++) { if(d[i] == 'a') d[i] = 'Z'; else if (d[i] == 'A') d[i] = 'z'; else if (d[i] == '0') d[i] = '9'; else if (isupper(d[i])) d[i] = tolower(d[i]) - 1; else if (islower(d[i])) d[i] = toupper(d[i]) - 1; else d[i]--; } return d; }