#include
typedef unsigned int uint;
typedef unsigned char uchar;
uchar smgcode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0x82,0xf8,0x80,0x90,0xff};//共阳数码管
uchar smgbit[]={0xfe,0xfd,0xfb,0xf7};
uchar value[]={0,0,0,0};
void delay(uint x)//延时函数
{
uchar i;
while(x–)for(i=0;i<120;i++);
}
void main(void)
{
uchar i,j;
uint s=0;
for(i=1;i<=100;i++)
s+=i;
value[0]=s;
value[2]=s00/100;
value[3]=s000/1000;
while(1)
{
for(j=0;j<4;j++)
{
P1=smgbit[j];
P2=smgcode[value[j]];
delay(10);
}
}
}