12xianshi.c

来自「C51 程序练习」· C语言 代码 · 共 40 行

C
40
字号
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp,shi,ge,wela;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};//0到F表格
void delay(uint z);
void main()
{
	temp=12;
	while(1)//大循环
	{
		shi=temp/10;//十位
		ge=temp%10;//个位
/*bai=temp/100;
shi=temp%100/10;
ge=temp/10;*/
		wela=0xfe;//亮十位
		P1=wela;
		P0=table[shi];
		delay(5);//快速延时动态显示

		wela=0xfd;//亮个位
		P1=wela;
		P0=table[ge];
		delay(5);	
	}
}

void delay(uint z)//延时子程序
{
	uint x,y;
	for(x=z;x>0;x--)
		for(y=110;y>0;y--);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?