diff --git a/multichoose.h b/multichoose.h index 51acb24..1e19a69 100644 --- a/multichoose.h +++ b/multichoose.h @@ -1,7 +1,7 @@ #ifndef __MULTICHOOSE_H #define __MULTICHOOSE_H -/* +/* multichoose.h -- n multichoose k for generic vectors @@ -58,7 +58,10 @@ std::vector< std::vector > multichoose(int k, std::vector& objects) { multiset.push_back(*a[i]); choices.push_back(multiset); j=k; - do { j--; } while(a[j]==b[j]); + do { + j--; + if (j<0) break; + } while(a[j]==b[j]); if (j<0) break; j_1=j; while(j_1<=k-1){ @@ -72,7 +75,7 @@ std::vector< std::vector > multichoose(int k, std::vector& objects) { j_1=q; } } - + return choices; }