All pastes #33760 Raw Edit

Someone

public text v1 · immutable
#33760 ·published 2005-12-15 12:42 UTC
rendered paste body
/* Created by Anjuta version 1.2.4 */
/*	This file will not be overwritten */

#include <iostream>
#include <math.h>

void numberCycle(int totalNum, int currentNum, int* selectFrom, int* addTo);

int main()
{
	int numbers[4] = {1,3,4,6};
	int testNumbers[4];
	numberCycle(4,1,numbers,testNumbers);
	return 0;
}

void numberCycle(int totalNum, int currentNum, int* selectFrom, int* addTo)
{
	for (int i = 0; i < (totalNum-currentNum); i++)
	{
		std::cout << "Reached loop " << i << " of recursion " << currentNum
			<< std::endl;
		addTo[currentNum - 1] = selectFrom[i];
		if (totalNum - currentNum == 1)
			std::cout << addTo[0] << ' '
				<< addTo[1] << ' ' << addTo[2] << ' ' << addTo[3] << std::endl;
		else
		{	
			int newSelectFrom[totalNum];
			for (int j = 0; j < totalNum; j++)
				newSelectFrom[j] = selectFrom[j];
			newSelectFrom[i] = newSelectFrom[totalNum-currentNum];
			numberCycle(totalNum, currentNum + 1, newSelectFrom, addTo);
		}
	}
	
}