how to out the multi-cycle in C
we all know the key-word break;
but it can only out one cycle, if we want to out multi-cycle, how we do ?
method 1:
use goto
method 2:
use a variable to store the state, if the state can meet, then we break; else we not, just like this
int whether_out = 0;
.......
{
whether_out = 1;
}
if (whether_out = 1)
break;
method 3:
we all know that when we do loop, we will determin
the cycle-conditions, we in the inner cycle, we can change the cycle-conditions to break out the cycle.
it like this
for (i = 0; i < max_i; i++)
{
for( j = 0; j < max_j; j++)
{
.......
........
i = max_i;
}
}
阅读(474) | 评论(0) | 转发(0) |