街角の风铃(计数器)
Dimly_dust · · 个人记录
比较简易,但可以看看。
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int a[100]={0};
HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
void go(int x,int y)
{
COORD pos;
pos.X=2*x;
pos.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
int ssr(int sdf)
{
for(int i=1;i<=sdf;i++)
{
if(a[i]!=9) return 0;
}
return 1;
}
void ints(int n,int s)
{
int x=s*5;
int y=s;
go(x,y);
cout<<" ";
go(x,y+1);
cout<<" ";
go(x,y+2);
cout<<" ";
go(x,y+3);
cout<<" ";
go(x,y+4);
cout<<" ";
if(n==0)
{
go(x,y);
cout<<"▉▉▉▉"<<endl;
go(x,y+1);
cout<<"▉ ▉"<<endl;
go(x,y+2);
cout<<"▉ ▉"<<endl;
go(x,y+3);
cout<<"▉ ▉"<<endl;
go(x,y+4);
cout<<"▉▉▉▉"<<endl;
}
if(n==1)
{
go(x,y);
cout<<" ▉▉ "<<endl;
go(x,y+1);
cout<<" ▉ "<<endl;
go(x,y+2);
cout<<" ▉ "<<endl;
go(x,y+3);
cout<<" ▉ "<<endl;
go(x,y+4);
cout<<" ▉▉▉"<<endl;
}
if(n==2)
{
go(x,y);
cout<<"▉▉▉▉"<<endl;
go(x,y+1);
cout<<" ▉"<<endl;
go(x,y+2);
cout<<"▉▉▉▉"<<endl;
go(x,y+3);
cout<<"▉ "<<endl;
go(x,y+4);
cout<<"▉▉▉▉"<<endl;
}
if(n==3)
{
go(x,y);
cout<<"▉▉▉▉"<<endl;
go(x,y+1);
cout<<" ▉"<<endl;
go(x,y+2);
cout<<" ▉▉▉"<<endl;
go(x,y+3);
cout<<" ▉"<<endl;
go(x,y+4);
cout<<"▉▉▉▉"<<endl;
}
if(n==4)
{
go(x,y);
cout<<"▉ ▉"<<endl;
go(x,y+1);
cout<<"▉ ▉"<<endl;
go(x,y+2);
cout<<"▉▉▉▉"<<endl;
go(x,y+3);
cout<<" ▉"<<endl;
go(x,y+4);
cout<<" ▉"<<endl;
}
if(n==5)
{
go(x,y);
cout<<"▉▉▉▉"<<endl;
go(x,y+1);
cout<<"▉ "<<endl;
go(x,y+2);
cout<<"▉▉▉▉"<<endl;
go(x,y+3);
cout<<" ▉"<<endl;
go(x,y+4);
cout<<"▉▉▉▉"<<endl;
}
if(n==6)
{
go(x,y);
cout<<"▉▉▉▉"<<endl;
go(x,y+1);
cout<<"▉ "<<endl;
go(x,y+2);
cout<<"▉▉▉▉"<<endl;
go(x,y+3);
cout<<"▉ ▉"<<endl;
go(x,y+4);
cout<<"▉▉▉▉"<<endl;
}
if(n==7)
{
go(x,y);
cout<<"▉▉▉▉"<<endl;
go(x,y+1);
cout<<" ▉"<<endl;
go(x,y+2);
cout<<" ▉ "<<endl;
go(x,y+3);
cout<<" ▉ "<<endl;
go(x,y+4);
cout<<" ▉ "<<endl;
}
if(n==8)
{
go(x,y);
cout<<"▉▉▉▉"<<endl;
go(x,y+1);
cout<<"▉ ▉"<<endl;
go(x,y+2);
cout<<"▉▉▉▉"<<endl;
go(x,y+3);
cout<<"▉ ▉"<<endl;
go(x,y+4);
cout<<"▉▉▉▉"<<endl;
}
if(n==9)
{
go(x,y);
cout<<"▉▉▉▉ "<<endl;
go(x,y+1);
cout<<"▉ ▉ "<<endl;
go(x,y+2);
cout<<"▉▉▉▉ "<<endl;
go(x,y+3);
cout<<" ▉ "<<endl;
go(x,y+4);
cout<<"▉▉▉▉ "<<endl;
}
}
void colour(int color)
{
SetConsoleTextAttribute(hOutput,color);
}
int sum=1;
int fenjie(int n)
{
for(int i=n;i>0;i/=10)
{
a[sum]=i%10;
sum++;
}
sum--;
}
int main()
{
int n,m;
cin>>m>>n;
fenjie(m);
for(int i=m;i<=n;i++)
{
for(int j=1;j<=sum;j++)
{
if(a[j]==10)
{
a[j+1]=a[j+1]+(a[j]/10);
a[j]=a[j]%10;
}
}
go(1,1);
for(int s=sum;s>=1;s--)
{
colour((i+s)%7+8);
ints(a[s],sum-s);
}
if(ssr(sum)) sum++;
a[1]++;
Sleep(10);
}
colour(15);
return 0;
}