Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
数字编码方式char DIGIT[10][8] = {"1110111", "0010010","1011101","1011011","0111010", "1101011", "1101111","1010010","1111111","1111011"}; 分别代表 0,1,3,4,5,6,7,8,9的方式 排列方式如下 000 1 2 1 2 333 4 5 4 5 666 这样不用太多次判断 或者用 char DIGIT[10][8] = {"-|| ||-", " | | ","- |-| -","- |- |-"," ||- | ", "-| - |-", "-| -||-","- | | ","-||-||-","-||- |-"}; 编码,这样不用判断每一位是'-','|'和空格 int leng = strlen(s); for (int i = 0; i < 7; i++) { if (i % 3 == 0) { for (int n = 0; n < leng; n++) { printf(" "); for (int k = 0; k < w; k++) printf("%c",DIGIT[s[n] - '0'][i]); if (n != leng - 1) printf(" "); else printf(" "); } printf("\n"); } else { for (int k = 0; k < w; k++) { for (int n = 0; n < leng; n++) { printf("%c",DIGIT[s[n] - '0'][i]); for (int m = 0; m < w; m++) printf(" "); printf("%c",DIGIT[s[n]-'0'][i+1]); if (n != leng - 1) printf(" "); } printf("\n"); } i++; } } printf("\n"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator