Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define TST_BIT(num, bit) ((1 << (bit)) & (num))
- const char dig_mask[11][10] =
- {{0x3f, 0x1, 0x3f, 0x3f, 0x21, 0x3f, 0x1, 0x3f, 0x3f, 0x3f},
- {0x21, 0x3, 0x1, 0x2, 0x21, 0x20, 0x2, 0x2, 0x21, 0x21},
- {0x21, 0x5, 0x1, 0x4, 0x21, 0x20, 0x4, 0x4, 0x21, 0x21},
- {0x21, 0x9, 0x1, 0x8, 0x21, 0x20, 0x8, 0x8, 0x21, 0x21},
- {0x21, 0x11, 0x1, 0x10, 0x21, 0x20, 0x10, 0x10, 0x21, 0x21},
- {0x21, 0x21, 0x1, 0x3f, 0x3f, 0x3f, 0x3f, 0x20, 0x3f, 0x3f},
- {0x21, 0x1, 0x2, 0x2, 0x1, 0x1, 0x21, 0x20, 0x21, 0x2 },
- {0x21, 0x1, 0x4, 0x4, 0x1, 0x1, 0x21, 0x20, 0x21, 0x4 },
- {0x21, 0x1, 0x8, 0x8, 0x1, 0x1, 0x21, 0x20, 0x21, 0x8 },
- {0x21, 0x1, 0x10, 0x10, 0x1, 0x1, 0x21, 0x20, 0x21, 0x10},
- {0x3f, 0x1, 0x3f, 0x20, 0x1, 0x3f, 0x3f, 0x20, 0x3f, 0x20}};
- void print_digits(const char *digits);
- int main (void)
- {
- char postal_code[6] = {0};
- printf("Enter a postal code: ");
- scanf("%6s", postal_code);
- printf("\n\n");
- print_digits(postal_code);
- system("pause > nul");
- return 0;
- }
- void print_digits(const char *digits)
- {
- int i, j, z;
- for (j = 0; j < 11; j++)
- {
- for (z = 0; digits[z]; z++)
- {
- for (i = 5; i >= 0; i--)
- printf("%c", TST_BIT(dig_mask[j][digits[z] - 48], i) ? 0xf9 : ' ');
- printf(" ");
- }
- putchar('\n');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement