All pastes #526099 Raw Edit

Mine

public text v1 · immutable
#526099 ·published 2007-05-31 17:40 UTC
rendered paste body
#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
	int n,m;
	void perm(int, int, int, int[]);
	int *array;
	cout << "Enter the size of the set: ";
	cin >> n;
	cout << "Enter the size of the subsets: ";	
	cin >> m;
	if (n<1) 
	{   
		cout << "Your set cannot be less than 1 element.  Program terminated";
		return 1;
	}
	if (n<m)
	{
		cout << "Your subset cannot be larger than your set.  Program terminated.";
	return 1;
	}
	array=new int[n];
	perm(0,n,m,array);  
}

void perm(int n, int max_size, int sub, int arr[ ])
{
	int i,j;
	if(n==max_size)
	{
	for (i=0; i<max_size; i++)  cout<<arr[i];
   	cout<<endl;
	return;  
   	}
	//for (j=0; j<sub; j++)
	//{
  	arr[n]=0;
  	perm(n+1,max_size,sub,arr);
	//}
  	arr[n]=1;
  	perm(n+1,max_size,sub,arr);
}