如何从一个布尔值,打破if语句的if语句中 [英] How to break out of an if statement from a boolean inside the if statement

查看:176
本文介绍了如何从一个布尔值,打破if语句的if语句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的事情

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

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

解决方案

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

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
}

这篇关于如何从一个布尔值,打破if语句的if语句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆