Loop i and j, where i != j
问题 For example I need to get all combinations of 2-values array with numbers {0, 1, 2} where this two numbers are not the same. I get 0 1 0 2 1 0 1 2 2 0 2 1 and I ignore 0 0 1 1 2 2 Now I use for (int i= 0; i < L ; i++) { for (int j = 0; j < L; j++) { if (i!= j) { but it is very slow? Any solution for this? L will be > 4000. What am I doing is finding every combinations of splitting matrix to 4 sub-matrices example: 3 | 0 2 -8 -8 5 | 3 2 2 3 2 | 5 2 1 4 ------------------- 3 4 -1 | 4 2 -3 6 2 |