|
If the expression is true, operator1 is executed and the control is given
to the operator that follows operator2 (operator2 is not executed). If
the expression is false, operator2 is executed.
もし式が true である場合、operator1 が実行されます。そしてコントロールは operator2 の後に続く処理に与えられます(operator2
は実行されません)。もし式が false である場合,operator2 が実行されます。
if (expression)
operator1
else
operator2
The else part of the if operator can be omitted. Thus, a divergence may
appear in nested if operators with omitted else part. In this case, else
addresses to the nearest previous if operator in the same block that has
no else part.
if処理は、else部分を省略することができます。したがって、else部分を省略すると、入れ子の if処理で分岐が現れるように見えます。この場合、elseの場所は同じブロック内にあって、最も近い
else部分を持たない if処理になります。
Examples:
例:
// The else part refers to the second if operator:
esle部分は2番目のif処理に属している
if(x>1)
if(y==2) z=5;
else z=6;
// The else part refers to the first if operator:
else部分は1番目のif処理に属している
if(x>l)
{
if(y==2) z=5;
}
else z=6;
// Nested operators
入れ子処理
if(x=='a')
{
y=1;
}
else if(x=='b')
{
y=2;
z=3;
}
else if(x=='c')
{
y = 4;
}
else Print("ERROR");
|