Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctype.h>
- #include <stdio.h>
- #include <string.h>
- static int decode(char *line) {
- const char *the = "the";
- int i, key = 0;
- while (!strstr(line, the)) {
- for (i = 0; i < strlen(line); i++) {
- if (isupper(line[i]))
- line[i] = (line[i] - 'A' + 1) % 26 + 'A';
- else if (islower(line[i]))
- line[i] = (line[i] - 'a' + 1) % 26 + 'a';
- }
- key++;
- }
- return key;
- }
- int main(void) {
- char line[BUFSIZ];
- int key;
- printf("cipher text: ");
- fgets(line, BUFSIZ, stdin);
- key = decode(line);
- printf("key: %d\n", key);
- printf("plain text: %s", line);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement