使用std::all_of
, 或姐妹无论你有什么逻辑我不知道它的正确性
while ( !std::all_of( std::begin(arr), std::end(arr), [](int i){ return i > 0; }) )
{
/* if all the elements in the array are greater than zero,
break the loop,
if they are not then restart the loop from the beginning
*/
}
Run Code Online (Sandbox Code Playgroud)