Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void segment(int num);
- int main(void) {
- int to_print;
- do {
- printf("Num (-1 to exit): ");
- scanf("%d", &to_print);
- segment(to_print);
- printf("\n");
- } while(to_print != -1);
- return 0;
- }
- void segment(int num) {
- int array[10][7] = {
- {1, 1, 1, 0, 1, 1, 1}, {0, 0, 1, 0, 0, 1, 0}, {1, 0, 1, 1, 1, 0, 1},
- {1, 0, 1, 1, 0, 1, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 0, 1, 0, 1, 1},
- {1, 1, 0, 1, 1, 1, 1}, {1, 0, 1, 0, 0, 1, 0}, {1, 1, 1, 1, 1, 1, 1},
- {1, 1, 1, 1, 0, 1, 1},
- };
- // Prima riga
- if (array[num][0]) {
- printf(" _ ");
- }
- printf("\n");
- // Seconda riga
- printf("%c", array[num][1] ? '|' : ' ');
- printf("%c", array[num][3] ? '_' : ' ');
- if (array[num][2]) printf("|");
- printf("\n");
- // Terza riga
- printf("%c", array[num][4] ? '|' : ' ');
- printf("%c", array[num][6] ? '_' : ' ');
- if (array[num][5]) printf("|");
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement