gounie 2019-12-01 21:45 采纳率: 0%
浏览 835

如何实现子函数的互相调用?

学习51 准备写用数码管显示做计算器 程序中有子函数互相调用 扫描一个时报错另一个图片说明

uchar KeyPro()
{   
    uint key_v;
        switch(KeyScan())
        {
        case 0xee: key_v=0; break;
        case 0xde: key_v=1; break;
        case 0xbe: key_v=2; break;
        case 0x7e: key_v=3; break;

        case 0xed: key_v=4; break;
        case 0xdd: key_v=5; break;
        case 0xbd: key_v=6; break;
        case 0x7d: key_v=7; break;

        case 0xeb: key_v=8; break;
        case 0xdb: key_v=9; break;

        case 0x7b:  break;

        case 0xe7: num=add(shi_1,ge_1); break;
        case 0xd7: num=sub(shi_1,ge_1); break;
        case 0xb7: num=mul(shi_1,ge_1); break;
        case 0x77: num=div(shi_1,ge_1); break;
        }
return key_v;
}
/***********************************************************************/
/*加法*/
/*//////////////////////////////*/
int add(uint shi_1,uint ge_1)
{
    if(flag==3)flag=0;
    while(1)
    {
        led1=0;
        switch(flag)
        {
            case 1: shi_2=KeyPro(); break;
            case 2: ge_2=KeyPro(); break;
        }if(flag==2) break;
    }
    shu1=shi_1*10+ge_1;
    shu2=shi_2*10+ge_2;
    shu=shu1+shu2;
    z++;
    return (shu);
}
/*减法*/
/*//////////////////////////////////////////////////////*/
int sub(uint shi_1,uint ge_1)
{
    if(flag==3)flag=0;
    while(1)
    {
        led2=0;
        switch(flag)
        {
            case 1: shi_2=KeyPro(); break;
            case 2: ge_2=KeyPro(); break;
        }if(flag==2) break;
    }
    shu1=shi_1*10+ge_1;
    shu2=shi_2*10+ge_2;
    shu=shu1-shu2;
    z++;
    return (shu);
}
/*乘法*/
/*////////////////////////////////////////////////////*/
int mul(uint shi_1,uint ge_1)
{
    if(flag==3)flag=0;
    while(1)
    {
        led3=0;
        switch(flag)
        {
            case 1: shi_2=KeyPro(); break;
            case 2: ge_2=KeyPro(); break;
        }if(flag==2) break;
    }
    shu1=shi_1*10+ge_1;
    shu2=shi_2*10+ge_2;
    shu=shu1*shu2;
    z++;
    return (shu);
}
/*除法*/
/*////////////////////////////////////////////////////*/
int div(uint shi_1,uint ge_1)
{
    if(flag==3)flag=0;
    while(1)
    {
        led4=0;
        switch(flag)
        {
            case 1: shi_2=KeyPro(); break;
            case 2: ge_2=KeyPro(); break;
        }if(flag==4) break;
    } 
    shu1=shi_1*10+ge_1;
    shu2=shi_2*10+ge_2;
    shu=shu1/shu2;
    z++;
    return (shu);
}
  • 写回答

1条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services