There are two ways to solve it:
Solution 1: use boolean confition instead of a second for loop
for (int i = 0; i < m; i++) {
int j = 0;
bool conditionOut=false;
while (!conditionOut && j<n)
{
if (some condition)
{
conditionOut =true;
break;
}
}
}
Solution 2: use goto (Stroustrup mentions it as onle of the few examples where goto is useful in C++)