All pastes #835292 Raw Edit

Something

public text v1 · immutable
#835292 ·published 2007-12-28 20:13 UTC
rendered paste body
bool can_be_done(int current_sum,int current_index,int ary[],int ary_len,int target_sum)
{
	if (current_sum == target_sum)
	{
		printf (ary[current_index] + " ");
		return true;
	}
	else if (current_sum > target_sum)
	{
		return false;
	}
	else
	{
		//TODO check that the next index exists in the ary
		if (can_be_done(current_sum + ary[current_index+1],current_index+1,ary,ary_len,target_sum))
		{
		}
		else
		{
			if(can_be_done(current_sum,current_index+1,ary,ary_len,target_sum))
			{
				print(ary[current_index])
			}
			else
			{
				return false;
			}
		}		
	}	
}