Answer the question
In order to leave comments, you need to log in
How to use the code from Antti Laaksonen's book?
I am studying A. Laaksonen's book "Olympiad Programming". There's a problem about generating subsets, and the following algorithm is given:
The function manipulates a vector subset that contains the elements of the subset. To start the search, we call the function with parameter 1.
void search(int k){
if (k == n + 1){
//обработать подмножество
} else{
//включить k в подмножество
subset.push_back(k);
search(k+1);
subset.pop_back();
search(k+1);
//не включить k в подмножество
}}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question