The_Law

Untitled

Sep 19th, 2018
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. enum
  4. {
  5.     SMALL_START = 11,
  6.     BIG_START = 37,
  7.     THIRD_BIT = 3,
  8.     SECOND_BIT = 2,
  9.     MAX_CODE = 63
  10. };
  11.  
  12. int
  13. main(void)
  14. {
  15.     char curr = getchar();
  16.     int diff;
  17.  
  18.     while (curr != EOF) {
  19.         _Bool skip = 0;
  20.  
  21.         if ('0' <= curr && curr <= '9')
  22.             diff = '0' - 1;
  23.         else if ('a' <= curr && curr <= 'z')
  24.             diff = 'a' - SMALL_START;
  25.         else if ('A' <= curr && curr <= 'Z')
  26.             diff = 'A' - BIG_START;
  27.         else
  28.             skip = 1;
  29.  
  30.         if (!skip) {
  31.             curr -= diff;
  32.             curr &= ~(1 << SECOND_BIT);
  33.             curr ^= (1 << THIRD_BIT);
  34.  
  35.             if (curr == 0)
  36.                 printf("@");
  37.             else if (curr == MAX_CODE)
  38.                 printf("#");
  39.             else
  40.                 printf("%c", curr + diff);
  41.         }
  42.         curr = getchar();
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment