您的位置 首页 厂商

用C51言语编写1+2+3 +‥‥‥+99+100的求和运算程序

includereg51h>typedefunsignedintuint;typedefunsignedcharuchar;ucharsmgcode[]={0xc0,0xf9,0xa4,0xb0

#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[1]=s0/10;
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);
}
}
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/255851.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部