Click here to Skip to main content
15,883,770 members
Articles / Programming Languages / C++

Combinatorial - A class to generate combinations of numbers

Rate me:
Please Sign up or sign in to vote.
2.33/5 (2 votes)
8 Oct 2008CPOL1 min read 21.1K   207   11  
A combinatorial class and example code.
// combi.cpp : Defines the entry point for the console application.
//

#include "combinatorial.h"
#include <iterator>

int main(int argc, char* argv[])
{
	ComboVector cv;
	if (argc != 4)
		return -1;

	int size = atoi(argv[1]);
	int len = atoi(argv[2]);
	int combin = atoi(argv[3]);

	if (len >= size)
	{
		cerr << " len cannot be >= size, exiting";
		return -2;
	}

	Comb::Combinations(size,len,combin,cv);
	copy(cv.begin(),cv.end(), ostream_iterator<string>(cout, "\n" ) );

	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Canada Canada
programmer interested in cooking and dogs..

Comments and Discussions