#include<reg51.h>
#define uchar unsigned char
sbit pluse1=P1^0
sbit pluse2=P1^1
uchar cnt,sec,dat
void t1isr() interrupt 3
{
TH1=(65536-50000)/256
TL1=(65536-50000)%256
if(cnt--)return
pluse1=~plsue1
cnt=20
sec++
}
main()
{
TMOD=0x10
TH1=(65536-50000)/256
TL1=(65536-50000)%256
TR1=1
ET1=1
EA=1
while(1)
{
while(sec<60)
pluse2=~pluse2
sec=0
}
}
#include<stdio.h>#define MAX 32
int main(void)
{
int i=0,n,a[MAX]
printf("请输入一个十进制整数:\n")
scanf("%d",&n)
while (n>0) //循环过程的始终,判断n是否能被2除尽
{
a[i] = n%2 //用数组存储每次除以2之后的余数,即断定奇偶性,对应二进制位上数值
i = i+1
n = n/2
}
printf("十进制整数转换为二进制数是:\n")
for(i >0i--)
printf("%d",a[i-1])
printf("\n")
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)