#include
#define uint unsigned int
#define uchar unsigned char
uchar a; //随机数
uint b;
uchar c;
uchar d;
bit e;
sbit k1=P3^2;
sbit k2=P3^3;
sbit k3=P3^4;
uchar led[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=114;y>0;y--)
{ a++; if(a>8){a=0;}}
}
void main()
{
while(1)
{
b++;
if(b>1500){c++;b=0;}
if(c>7){c=0;}
P0= led[c];
if(k1==0){delay(50);if(k1==0){e=~e;}}
while(e)
{ if(a==0){P0=led[2];}; if(a==5){P0=led[2];};if(a==2){P0=led[2];};
if(a==1){P0=led[4];}; if(a==7){P0=led[4];};if(a==4){P0=led[4];};
if(a==3){P0=led[6];}; if(a==8){P0=led[6];};if(a==6){P0=led[6];};
if(k1==0){delay(50);if(k1==0){e=~e;}}
}
}
}