Home > Back-end >  A recursive problems need to solve with c
A recursive problems need to solve with c

Time:12-16

[problem description] nums given an array and a target value target, calculating all can make the Numbers and is equal to the target value in the array nums target number of combinations, each number in the array can be used only once,
[form] input input consists of three parts, the first line of input an integer size, according to the array size; The second line of the input size integers, separated by Spaces, said nums in the array size number; The third line, enter an integer target,
[form] output output an integer, said array nums all Numbers and is equal to the target value in the target number of combinations,
[] sample input 5

5 1 1 2

5
[sample output] 2
[example] 1. All the input and output are all positive integer type int, (2) the combination of the repeat calculation only once, and (3) each of the array number can only use a 4. The input has,2,2 {1} and {5} number two combinations, so the output 2, 5. The size is 30 [1], the range of
This topic I check a lot of information and also tried many times, but still not to the purpose, the recursion in the end how to just can get rid of the combination of the repeat? The return value should how to write?
Hope everybody who grant instruction!!!!!!

CodePudding user response:

First the sorting, C (1, n) to C (n, n) combination of all items, again to the summation item combination, conform to the left,
Just to heavy or not do, in judgment
  • Related