Guest User

Untitled

a guest
Oct 23rd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int gethex() {
  5.   register int c;
  6.   while ((c = getchar()) >= 0) {
  7. _gethex:
  8.     if (c != '#') {
  9.       c -= 48; // convert '0' - '9'
  10.       if (c < 0) continue; // invalid, ignore
  11.       if (c > 48) c -= 39; // convert 'a' - 'f'
  12.       return c;
  13.     }
  14.     while ((c = getchar()) != '\n');
  15.     goto _gethex;
  16.   }
  17.   exit(0);
  18. }
  19. int main() {
  20.   register int hi,lo;
  21.   while (1) {
  22.     hi = gethex() << 4;
  23.     lo = gethex();
  24.     putchar(hi + lo);
  25.   }
  26. }
Add Comment
Please, Sign In to add comment