如何从一个布尔值,打破if语句的if语句中语句、布尔值、if

2023-09-05 03:52:13 作者:桃花侠大战菊花怪

我有这样的事情

 一个布尔= TRUE;
布尔B =真实;
布尔积= TRUE;
如果(图)
{
    如果一个)
    {
        如果(B)的
            B = FALSE;
        其他
            B =真实;
    //做一些有意义的东西在这里
    }
//要执行一些东西在这里需要
}
 

我想打出来的if语句测试一个当B变成假的。有点像破发,并继续在循环中。有任何想法吗? 编辑:对不起,忘了,包括大的if语句。我想打出来,如果​​(一)当b是假的,但不是打出来的,如果(图)。

解决方案

 如果(图)
{
    如果一个)
    {
        B =!;
        如果(B)的
        {
            //做一些有意义的东西在这里
        }
    }
    //要执行一些东西在这里需要
}
 

深入理解Python中的if语句

I have something like this

bool a = true;
bool b = true;
bool plot = true;
if(plot)
{
    if(a)
    {
        if(b)
            b = false;
        else
            b = true;
    //do some meaningful stuff here
    }
//some more stuff here that needs to be executed
}

I want to break out of the if statement that tests a when b turns false. Kind of like break and continue in loops. Any ideas? Edit: sorry forgot to include the big if statement. I want to break out of if(a) when b is false but not break out of if(plot).

解决方案

if(plot)
{
    if(a)
    {
        b= !b;
        if( b )
        {
            //do something meaningful stuff here
        }
    }
    //some more stuff here that needs to be executed
}