Advertisement
Guest User

Untitled

a guest
Jun 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. /* rot13 algorithm. Very Simple and Interesting */
  2.  
  3. #include<stdio.h>
  4. #define ROT 13
  5.  
  6. void rot13(char cadena[]){
  7. int c,e;
  8. int i = 0;
  9. while(cadena[i] != 0){
  10. c = cadena[i];
  11. if(c >='A' && c <='Z')
  12. {
  13. if((e = c + ROT) <= 'Z')
  14. putchar(e);
  15. else
  16. {
  17. e = c - ROT;
  18. putchar(e);
  19. }
  20. }
  21. else if(c >='a' && c <='z')
  22. {
  23. if((e= c + ROT) <= 'z')
  24. putchar(e);
  25. else
  26. {
  27. e = c - ROT;
  28. putchar(e);
  29. }
  30. }
  31. else
  32. putchar(c);
  33. i++;
  34. }
  35. }
  36.  
  37. void main(){
  38. char input[100];
  39. scanf("%[^\n]%*c", input);
  40. rot13(input);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement