Is it possible for a for loop with 2 variables to stop incrementing only one of the variable when a condition is met ? For example
for(int i = 0, j = 0; i < 5 && j < 10; i++, j++)
{
cout << i << " " << j << endl;
}
and the output would look something like
0 0
1 1
2 2
3 3
4 4
4 5
4 6
4 7
4 8
4 9
This is my actual code. I wanted the condition for both variables
cout << sp.dets.size() << " " << gt.groundtruth.size() << endl;
for (int i = 0, j = 0; i < sp.dets.size() && j < gt.groundtruth.size(); j < gt.groundtruth.size() ? j++ : j, i < sp.dets.size() ? i++ : i)
{
cout << i << " " << j << endl;
}
sp.dets.size = 0
gt.groundtruth.size() = 8
It would be nice if the solution works for any number i.e. i > j or i < j or i = 0 or j = 0