C/C++の宿題を片付けます 116代目at TECH
C/C++の宿題を片付けます 116代目 - 暇つぶし2ch784:デフォルトの名無しさん
08/10/27 00:17:26
>>777
#include<stdio.h>
#include<string.h> // memset
#define WIDTH (4*7)
#define HEIGHT (5)
void numset(char screen[HEIGHT][WIDTH], int x, int y, int num){
static const char font[][4*10+1]={ // 0123456789 の順に 3x5 で文字+数字間と末尾に一文字空白入れる
"*** * *** *** * * *** *** *** *** *** ",
"* * * * * * * * * * * * * * ",
"* * * *** *** *** *** *** * *** *** ",
"* * * * * * * * * * * * * ",
"*** * *** *** * *** *** * *** *** ",
};
int ix, iy;
for(iy=0;iy<5;iy++)
for(ix=0;ix<4;ix++) screen[y+iy][x+ix]=font[iy][num*4+ix];
}
void display_number(long value){
char screen[HEIGHT][WIDTH];
long div, x, y=0;
if(value<0 || value>1000000) return;
memset(screen, '\0', sizeof(screen));
for(div=1;value/div>=10;div*=10);
for(x=0;div>0;div/=10,x+=4) numset(screen, x, y, (value/div)%10);
for(y=0;y<HEIGHT;y++) printf("%s\n", screen[y]);
}
int main(int argc, char *argv[]){
int num=123456;
if(argc==2) sscanf(argv[1], "%d", &num);
display_number(num);
return 0;
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch