打印数字
小明寫了一個有趣的程序,給定一串數字。
它可以輸出這串數字拼出放大的自己的樣子。
比如“2016”會輸出為:
22222 00000 1 6666
2 2 0 0 1 1 6
2 0 0 1 666666
2 0 0 1 6 6
2 0 0 1 6 6
2 2 0 0 1 6 6
2222222 00000 1111 66666
請仔細分析代碼,填寫劃線部分缺少的內容。
#include <stdio.h> #include <string.h> #define ZIW 8 #define ZIH 7 void f(int n) {char cc[100];int i,j;char di[][ZIH][ZIW] = {{" 00000 ","0 0","0 0","0 0","0 0","0 0"," 00000 "},{" 1 "," 1 1 "," 1 "," 1 "," 1 "," 1 "," 1111"},{" 22222 ","2 2"," 2"," 2 "," 2 "," 2 2","2222222"},{" 33333 ","3 3"," 3"," 3333 "," 3","3 3"," 33333 "},{" 44 "," 4 4 "," 4 4 ","4 4 ","4 4 ","4444444"," 4 "},{" 55555 "," 5 ","555555 "," 5"," 5","5 5"," 55555 "},{" 6666 ","6 ","666666 ","6 6","6 6","6 6"," 66666 "},{"7777777","7 7 "," 7 "," 7 "," 7 "," 7 "," 7 "},{" 88888 ","8 8","8 8"," 88888 ","8 8","8 8"," 88888 "},{" 99999 ","9 9","9 9"," 999999"," 9","9 9"," 99999 "}};sprintf(cc, "%d", n);for(i=0; i<ZIH; i++){for(j=0; j<strlen(cc); j++){printf("%s ", di[cc[j] - '0'][i] ); //填空位置 }printf("\n");} }int main() {f(2016);return 0; }?
注意:只提交劃線部分缺少的代碼,不要添加任何題面已有代碼或符號。
也不要提交任何說明解釋文字等。
?
轉載于:https://www.cnblogs.com/8023spz/p/10731853.html
總結
- 上一篇: 面试题:DUBBO源码使用了哪些设计模式
- 下一篇: 再有人问你MySql 的隔离级别是什么,