UVA 706 - LCD Display(液晶显示器)
/* 别人的巧妙方法。 */ #include <cstdio> #include <cstring> #include <iostream> using namespace std; char n1[11] = {"- -- -----"}; //笔画1被数字0, 2, 3, 5, 6, 7, 8, 9覆盖 char n2[11] = {"| ||| ||"}; //笔画2被数字0, 4, 5, 6, 8, 9覆盖 char n3[11] = {"||||| |||"}; //笔画3被数字0, 1, 2, 4, 7, 8, 9覆盖 char n4[11] = {" ----- --"}; //笔画4被数字2, 3, 4, 5, 6, 8, 9覆盖 char n5[11] = {"| | | | "}; //笔画5被数字0, 2, 6, 8覆盖 char n6[11] = {"|| |||||||"}; //笔画6被数字0, 1, 3, 4, 5, 6, 7, 8, 9 覆盖 char n7[11] = {"- -- -- --"}; //笔画7被数字0, 2, 3, 5, 6, 8, 9 覆盖 int main() { int s; char szNumber[20]; int nDigit , nLength, i , j , k; while(1) { scanf( "%d%s", &s, szNumber); if (s == 0) break; nLength = strlen(szNumber); for (i = 0 ; i < nLength ; i++) { //输出所有数字的笔画1 nDigit = szNumber[i] - '0'; printf(" "); for (j = 0 ; j < s ; j++) //一个笔画由s个字符组成 printf("%c", n1[nDigit]); printf(" "); if (i < nLength-1) printf(" "); } printf("\n"); for (i = 0 ; i < s ; i++) { //输出所有数字的笔画2和笔画3 for (j = 0 ; j < nLength ; j++) { nDigit = szNumber[j] - '0'; printf("%c", n2[nDigit]); for (k = 0 ; k < s ; k++) printf(" "); //笔画2和笔画3之间的空格 printf("%c", n3[nDigit]); if (j < nLength-1) printf(" "); } printf("\n"); } for (i = 0 ; i < nLength ; i++) { //输出所有数字的笔画4 printf(" "); nDigit = szNumber[i] - '0'; for (j = 0 ; j < s ; j++) printf("%c", n4[nDigit]); printf(" "); if (i < nLength-1) printf(" "); } printf("\n"); for (i = 0 ; i < s ; i++) { //输出所有数字的笔画5和笔画6 for (j = 0 ; j < nLength ; j++) { nDigit = szNumber[j] - '0'; printf("%c", n5[nDigit]); for (k = 0 ; k < s ; k++) printf(" "); //笔画5和笔画6之间的空格 printf("%c", n6[nDigit]); if (j < nLength-1) printf(" "); } printf("\n"); } for (i = 0 ; i < nLength ; i++) { //输出所有数字的笔画7 printf(" "); nDigit = szNumber[i] - '0'; for (j = 0 ; j < s ; j++) printf("%c", n7[nDigit]); printf(" "); if (i < nLength-1) printf(" "); } printf("\n"); printf("\n"); } return 0; }
补充:软件开发 , C++ ,