就是一个模拟题,显示出0-9这些数字的形状。我写的代码比较繁琐,牛人们忽略吧。
#include <iostream>
#include <stdio.h>
using namespace std;
char digit[9][11];
int s,n,d[10];
void init()
{
memset(digit,'\0',sizeof(digit));
strcpy(digit[0],"1011011111");
strcpy(digit[1],"1000111011");
strcpy(digit[2],"0011111011");
strcpy(digit[3],"1111100111");
strcpy(digit[4],"1011011011");
strcpy(digit[5],"1010001010");
strcpy(digit[6],"1101111111");
}
int main()
{
init();
int i,j,k,cnt,mm;
while(1)
{
scanf("%d%d",&s,&n);
if(!s && !n)
break;
int tmp=n;
cnt=0;
do
{
j=tmp%10;
d[cnt++]=j;
tmp=tmp/10;
}while(tmp>0);
// cout<<cnt<<endl;
for(i=0;i<5;i++)
{
if(i%2 == 0)
{
for(j=cnt-1;j>=0;j--)
{
printf(" ");
if(digit[i][d[j]]=='1')
{
for(k=0;k<s;k++)
printf("-");
}
else
{
for(k=0;k<s;k++)
printf(" ");
}
printf(" ");
printf(" ");
}
}
else
{
for(k=0;k<s;k++)
{
// cout<<k<<"kk"<<endl;
for(j=cnt-1;j>=0;j--)
{
if(i == 1)
{
if(digit[1][d[j]]=='1')
printf("|");
else
printf(" ");
for(mm=0;mm<s;mm++)
printf(" ");
if(digit[3][d[j]]=='1')
printf("|");
else
printf(" ");
}
else
{
if(digit[5][d[j]]=='1')
printf("|");
else
printf(" ");
for(mm=0;mm<s;mm++)
printf(" ");
if(digit[6][d[j]]=='1')
printf("|");
else
printf(" ");
}
printf(" ");
}
if(k != (s-1))
printf("\n");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}