欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 這個程序就是報DTSY.C(55): error C171: 'break': missing enclosing loop [打印本頁]

作者: 666n人    時間: 2024-2-18 21:09
標題: 這個程序就是報DTSY.C(55): error C171: 'break': missing enclosing loop
#include "reg52.h"
#include "MATH.h"
typedef unsigned int u16;       
typedef unsigned char u8;
typedef unsigned long u32;
typedef int uf16;       
typedef char uf8;
typedef long uf32;
sbit KEY1=P3^1;
sbit KEY2=P3^0;
sbit KEY3=P3^2;
sbit KEY4=P3^3;
sbit up=P2^0;
sbit down=P2^1;
#define KEY1_PRESS        1
#define KEY2_PRESS        2
#define KEY3_PRESS        3
#define KEY4_PRESS        4
#define KEY_UNPRESS        0
u8 current=0;
u8 call=0;
u8 key=0;
u8 Floordifference=0;       
void delay_10us(u32 ten_us)
{
        while(ten_us--);       
}
u8 key_scan(u8 mode)
{
        static u8 key=1;

        if(mode)key=1;
        if(key==1&&(KEY1==0||KEY2==0||KEY3==0||KEY4==0))
        {
                delay_10us(1000);
                key=0;
                if(KEY1==0)
                        return KEY1_PRESS;
                else if(KEY2==0)
                        return KEY2_PRESS;
                else if(KEY3==0)
                        return KEY3_PRESS;
                else if(KEY4==0)
                        return KEY4_PRESS;       
        }
        else if(KEY1==1&&KEY2==1&&KEY3==1&&KEY4==1)       
        {
                key=1;
                return KEY_UNPRESS;                               
        }
        return KEY_UNPRESS;               
}
void exit()
{
break;
}
void assignment()
{
         while(1)
        {       
                        key=key_scan(0);
                        if(key==KEY1_PRESS)
                        {
                                call=KEY1_PRESS;
                        }
                        else if(key==KEY2_PRESS)
                        {
                                call=KEY2_PRESS;
                        }
                        else if(key==KEY3_PRESS)
                        {
                                call=KEY3_PRESS;
                    }
                        else if(key==KEY4_PRESS)
                        {
                                call=KEY4_PRESS;
                        }
                        else if(KEY1==0||KEY2==0||KEY3==0||KEY4==0)
                        {
                                exit();
                        }
        }
}
void lift()
{
        assignment();
        if(current<call)
        {
            Floordifference=call-current;
                current=call;
                down=0;
                delay_10us(abs(Floordifference)*5000);
        }
        if(current>call)
        {
            Floordifference=current-call;
                current=call;
                up=0;
                delay_10us(Floordifference*5000);
        }               
}
void main()
{
lift();
大家看一下。


作者: 1600277881    時間: 2024-2-19 00:39
Break 不能這樣用, Break原則上是個goto 的語句, 在函數里再goto 就錯了
你可以用 #define exit()  break
作者: Hephaestus    時間: 2024-2-19 06:13
把while(1)改成while(!(KEY1||KEY2||KEY3||KEY4)),并把while(1)內層對應語句刪掉,exit()相關語句也可以刪掉。




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1