#define N 10 //最多可以輸入10個數字 #i nclude <stdio.h> int check(char array[],int n) { //檢查輸入是否全為數字 int i; for(i=0;i<n;i++) if(array[i]<'0'||array[i]>'9') return -1; return 1; } main() { char alpha[70][4]={{'*','*','*','*'},{'*',' ',' ','*'},{'*',' ',' ','*'},{'*',' ',' ','*'}, {'*',' ',' ','*'},{'*',' ',' ','*'},{'*','*','*','*'},{' ',' ',' ','*'}, {' ',' ',' ','*'},{' ',' ',' ','*'},{' ',' ',' ','*'},{' ',' ',' ','*'}, {' ',' ',' ','*'},{' ',' ',' ','*'},{'*','*','*','*'},{' ',' ',' ','*'}, {' ',' ',' ','*'},{'*','*','*','*'},{'*',' ',' ',' '},{'*',' ',' ',' '}, {'*','*','*','*'},{'*','*','*','*'},{' ',' ',' ','*'},{' ',' ',' ','*'}, {'*','*','*','*'},{' ',' ',' ','*'},{' ',' ',' ','*'},{'*','*','*','*'}, {' ','*',' ',' '},{'*',' ','*',' '},{'*',' ','*',' '},{'*','*','*','*'}, {' ',' ','*',' '},{' ',' ','*',' '},{' ',' ','*',' '},{'*','*','*','*'}, {'*',' ',' ',' '},{'*',' ',' ',' '},{'*','*','*','*'},{' ',' ',' ','*'}, {' ',' ',' ','*'},{'*','*','*','*'},{'*',' ',' ',' '},{'*',' ',' ',' '}, {'*',' ',' ',' '},{'*','*','*','*'},{'*',' ',' ','*'},{'*',' ',' ','*'}, {'*','*','*','*'},{'*','*','*','*'},{' ',' ',' ','*'},{' ',' ',' ','*'}, {' ',' ',' ','*'},{' ',' ',' ','*'},{' ',' ',' ','*'},{' ',' ',' ','*'}, {'*','*','*','*'},{'*',' ',' ','*'},{'*',' ',' ','*'},{'*','*','*','*'}, {'*',' ',' ','*'},{'*',' ',' ','*'},{'*','*','*','*'},{'*','*','*','*'}, {'*',' ',' ','*'},{'*',' ',' ','*'},{'*','*','*','*'},{' ',' ',' ','*'}, {' ',' ',' ','*'},{' ',' ',' ','*'}}; //把10個數字元号化,7行4列為一個數字 int row,count,col,n; // char input[N+1]; int length; printf("/nPlease input at most 10 digital to display/n"); scanf("%s",input); length=strlen(input); //length用來記錄實際輸入的數字個數 if(check(input,length)==-1) { printf("/ninput error,exit!"); return; } for(row=0;row<7;row++) { //7行 printf("/n"); for(count=0;count<length;count++) { //控制每個數字 n=input[count]-'0'; for(col=0;col<4;col++) { //每個數字4列 printf("%c",alpha[n*7+row][col]); } printf(" "); //每行中數字間隔 } } } |