#include
#define uchar unsigned char
#define uint unsigned int
//共阴数码管七段码
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,0x7f,0x6f,0x77};
uchar code table2[]={5,4,3,2};//这就是学号的后4位,自行修改
void display()//4位显示子程序
{
P0=~(table[ table2[0]]);
wei1=0;
Delay1ms(2);
wei1=1;
P0=~(0x80|table[ table2[1]]);
wei2=0;
Delay1ms(2);
wei2=1;
P0=~(table[ table2[2]]);
wei3=0;
Delay1ms(2);
wei3=1;
P0=~(table[ table2[3]);
wei4=0;
Delay1ms(2);
wei4=1;
}
void Delay1ms(uint i) //1ms延时程序
{
uint j;
for(;i>0;i--)
{
for(j=0;j<164;j++)
{;}
}
}
void main(void )//主程序
{
while(1)
{
display();
}
}
wei4=0;上面少了个中括号