while (a)
{
    ...
    ...
    if (b) 
        break;
    ...
    ...
    ...
}

建议改为

while (a && !b)
{
    ...
    ...
    if (!b) 
   {
    ...
    ...
    ...

    }
}

You have no rights to post comments