title: Generating combinations in c++
body: <p>I have been searching a source code for generating combination using c++. I found some advanced codes for this but that is good for only specific number predefined data. Can anyone give me some hints, or perhaps, some idea to generate combination. As an example, suppose the set S = { 1, 2, 3, ...., n} and we pick r= 2 out of it. The input would be <code>n</code> and <code>r</code>.In this case, the program will generate arrays of length two, like 5 2 outputs  1 2, 1 3, etc.. I had difficulty in constructing the algorithm. It took me a month thinking about this.</p>