#include <stdio.h> #include <string.h> #include <conio.h> char nums[10][5][3] = { {{' ', '-', ' '}, {'|', ' ', '|'}, {' ', ' ', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}}, {{' ', ' ', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}}, {{' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}, {'|', ' ', ' '}, {' ', '-', ' '}}, {{' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}}, {{' ', ' ', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}}, {{' ', '-', ' '}, {'|', ' ', ' '}, {' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}}, {{' ', '-', ' '}, {'|', ' ', ' '}, {' ', '-', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}}, {{' ', '-', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}, {' ', ' ', '|'}, {' ', ' ', ' '}}, {{' ', '-', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}}, {{' ', '-', ' '}, {'|', ' ', '|'}, {' ', '-', ' '}, {' ', ' ', '|'}, {' ', '-', ' '}}}; int main() { int i, j, k, num, x, jj, kk; int n, m, digits[20]; freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); while(scanf("%d%d", &n, &m) != EOF) { if(!n && !m) break; i = 0; if(m == 0) //注意0 { x = 1; digits[0] = 0; } else { //转为单个数字放在数组里 while(m > 0) { digits[i] = m % 10; m = m / 10; i++; } x = i; //5
}
//放大过程 for(j=0; j<2*n+3; j++) { jj = j; if(j > 0 && j <= n) jj = 1; if(j == n+1) jj = 2; if(j > n+1 && j < 2*n+3-1) jj = 3; if(j == 2*n+3-1) jj = 4; for(i=x-1; i>=0; i--) { for(k=0; k< n+2; k++) { kk = 0; if(k > 0 && k < n+1) kk = 1; if(k == n+1) kk = 2; printf("%c", nums[digits[i]][jj][kk]); } printf(" "); //数字之间要有空格 } printf("\n"); } printf("\n"); //输出一个数据后要有空行 }
getch(); return 0; }
|