LegoDrifter

Untitled

Jan 20th, 2021
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. void cipher(char *word, int x) {
  5. if(*word == 0) return;
  6. if(isalpha(*word)) {
  7. char first = 'a';
  8. if(isupper(*word))
  9. first = 'A';
  10. *word = first + (*word + x -first) % 26;
  11. }
  12. cipher(++word, x);
  13. }
  14.  
  15. int main() {
  16. int n, x;
  17. scanf("%d %d\n", &n, &x);
  18. int i;
  19. char word[80];
  20. for(i = 0; i < n; ++i) {
  21. fgets(word, 80, stdin);
  22. cipher(word, x);
  23. printf("%s", word);
  24. }
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment