类似电子钟的那种显示数字的方式,怎么用C++实现,每个数字占据5*3大小的字符区域?急求!!
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
2个回答
展开全部
#include<iostream>
using namespace std;
int main()
{
char s[10][9] ={{' ','_',' ','|',' ','|','|','_','|'},
{' ',' ',' ',' ',' ','|',' ',' ','|'},
{' ','_',' ',' ','_','|','|','_',' '},
{' ','_',' ',' ','_','|',' ','_','|'},
{' ',' ',' ','|','_','|',' ',' ','|'},
{' ','_',' ','|','_',' ',' ','_','|'},
{' ','_',' ','|','_',' ','|','_','|'},
{' ','_',' ',' ',' ','|',' ',' ','|'},
{' ','_',' ','|','_','|','|','_','|'},
{' ','_',' ','|','_','|',' ','_','|'}};
char st[36];
int num[4],a,b,c,d;
while (cin>>a>>b>>c>>d)
{
num[0]=a; num[1]=b; num[2]=c; num[3]=d;
for (int i=1,x=0,y=3; i<=3; i++,x+=3,y+=3) //分3次输出
{
for (int j=0; j<=3; j++) //每次输出4个数字的部分
for (int k=x; k<y; k++) cout<<s[num[j]][k];
cout<<endl;
}
}
}
using namespace std;
int main()
{
char s[10][9] ={{' ','_',' ','|',' ','|','|','_','|'},
{' ',' ',' ',' ',' ','|',' ',' ','|'},
{' ','_',' ',' ','_','|','|','_',' '},
{' ','_',' ',' ','_','|',' ','_','|'},
{' ',' ',' ','|','_','|',' ',' ','|'},
{' ','_',' ','|','_',' ',' ','_','|'},
{' ','_',' ','|','_',' ','|','_','|'},
{' ','_',' ',' ',' ','|',' ',' ','|'},
{' ','_',' ','|','_','|','|','_','|'},
{' ','_',' ','|','_','|',' ','_','|'}};
char st[36];
int num[4],a,b,c,d;
while (cin>>a>>b>>c>>d)
{
num[0]=a; num[1]=b; num[2]=c; num[3]=d;
for (int i=1,x=0,y=3; i<=3; i++,x+=3,y+=3) //分3次输出
{
for (int j=0; j<=3; j++) //每次输出4个数字的部分
for (int k=x; k<y; k++) cout<<s[num[j]][k];
cout<<endl;
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询