谢谢你!
#include <stdio.h> #define arrsize(array) sizeof(array) / sizeof(*array) int get(index, value) { return (value & (1 << index)) >> index; } void draw(int * number, int size) { int i, j; for(i = 0; i < size; i++) { for(j = 7; j > -1; j--) get(j, number[i]) ? putchar('F') && putchar(' ') : putchar(' ') && putchar(' '); putchar('\n'); } } int main(void) { int numbers[10][5] = { {15, 9, 9, 9, 15}, {1, 3, 1, 1, 1}, {15, 1, 15, 8, 15}, {15, 1, 15, 1, 15}, {9, 9, 15, 1, 1}, {15, 8, 15, 1, 15}, {15, 8, 15, 9, 15}, {15, 1, 2, 2, 2}, {15, 9, 15, 9, 15}, {15, 9, 15, 1, 15}, }; int n, i, j; while(!scanf("%d", &n) || n < 0 || n > 9) ; draw(numbers[n], arrsize(numbers[n])); return 0; } /* Output: ------------------------------------------------------------ 0 F F F F F F F F F F F F F F Process returned 0 (0x0) execution time : 1.625 s Press any key to continue. ------------------------------------------------------------- 1 F F F F F F Process returned 0 (0x0) execution time : 0.984 s Press any key to continue. ------------------------------------------------------------- 2 F F F F F F F F F F F F F F Process returned 0 (0x0) execution time : 0.938 s Press any key to continue. ------------------------------------------------------------- 3 F F F F F F F F F F F F F F Process returned 0 (0x0) execution time : 0.938 s Press any key to continue. ------------------------------------------------------------- 4 F F F F F F F F F F Process returned 0 (0x0) execution time : 0.906 s Press any key to continue. ------------------------------------------------------------- 5 F F F F F F F F F F F F F F Process returned 0 (0x0) execution time : 1.078 s Press any key to continue. ------------------------------------------------------------- 6 F F F F F F F F F F F F F F F Process returned 0 (0x0) execution time : 1.031 s Press any key to continue. ------------------------------------------------------------- 7 F F F F F F F F Process returned 0 (0x0) execution time : 0.938 s Press any key to continue. ------------------------------------------------------------- 8 F F F F F F F F F F F F F F F F Process returned 0 (0x0) execution time : 0.828 s Press any key to continue. ------------------------------------------------------------- 9 F F F F F F F F F F F F F F F Process returned 0 (0x0) execution time : 0.859 s Press any key to continue. ------------------------------------------------------------- */这样也可以哦。
#include<stdio.h> int main() { int i,t; loop: printf("please input the number\n"); scanf("%d",&t); if(t>=0&&t<10) { if(t==0||t==5||t==2||t==3||t==6||t==7||t==8||t==9)//第一部分 printf(" FFFFFFFFFF\n"); for(i=0;i<6;i++)//第二部分 { if(t==0||t==8||t==9||t==4) printf(" F"); if(t==5||t==6) printf(" F\n"); if(t==2||t==3||t==4||t==0||t==1||t==7||t==8||t==9) printf(" F\n"); } if(t==2||t==3||t==4||t==5||t==6||t==8||t==9)//第三部分 printf(" FFFFFFFFFF\n"); for(i=0;i<6;i++)//第四部分 { if(t==0||t==6||t==8) printf(" F"); if(t==2) printf(" F\n"); if(t!=2) printf(" F\n"); } if(t==0||t==2||t==3||t==5||t==6||t==8||t==9)//第五部分 printf(" FFFFFFFFFF"); } else printf("input wrong please input again\n"); goto loop; return 0; }都抢我位置呢 呵呵我也奉上代码 有规律的