algorithm - "For" loop for all possible combinations without repetition -


i have table of values, , need compare of them. problem is, don't want compare same values 2 times (for example, loop compares values 1 - 2, 1 - 3, 2 - 1, , 2 - 1 same 1 - 2). wrote loop inside loop looks this:

for (int = 0; < numberofsets; i++) {         (int j = 1; j < numberofsets; j++) {          //compare element , j here     } } 

but how can modify loop skip repetitions? tried far incrasing j when == j:

for (int = 0; < numberofsets; i++) {         (int j = 1; j < numberofsets; j++) {               if(i == j) {                 j++;             } else {                 //compare element , j             }     } } 

but doesn't seem work correctly. there better way loop way want to?

simply start inner loop j = + 1.

for (int = 0; < numberofsets; i++) {     (int j = + 1; j < numberofsets; j++) {         // stuff     } } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -