[ad_1]
You have different indexes in the loops:
for(int k = j+1; k < n; ++k)
for(int l = k+1; l < n; ++l)
and
for k in range(i+2, n):
for l in range(i+3, n):
Basically, the indexes in the inner loops in your C++ code change accordingly to the loop that is one line above them. In your python code, all the indexes change only when the first loop changes.
[ad_2]
solved The results of python and c++ are different for nested for statements [closed]