Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- #include <stdlib.h>
- #include <string.h>
- int
- main(int argc, char *argv[])
- {
- if (argc != 1)
- return 1;
- int k = atoi(argv[1]);
- string phrase = GetString();
- int length = strlen(phrase);
- for (int i = 0, n = length; i < n; i++)
- {
- if (phrase[i] >= 65 && phrase[i] <= 90)
- phrase[i] = ((phrase[i] + k) - 65) % 26 + 65;
- else if (phrase [i] >= 97 && phrase[i] <= 122)
- phrase[i] = ((phrase[i] + k) - 97) % 26 + 97;
- else
- phrase[i] = phrase [i];
- printf("%c", phrase[i]);
- }
- printf("\n");
- return 0;
- }
Add Comment
Please, Sign In to add comment