05-12-2016, 08:49 AM
Language of coding is C only. No other language is allowed for this.
You will be given a file with two lines. First line will contain two integers separated by commas(say X,Y). In the next line there will be Y number of integers again separated by commas. You should be able to output all the possible combinations from the Y integers (an integer can be used infinite number of times) which addition will give the value X.
Example Input
10,4
2,5,3,6
The output will be:
2+2+2+2+2
2+2+3+3
2+2+6
2+3+5
5+5
The order of the output does not matter
You will be given a file with two lines. First line will contain two integers separated by commas(say X,Y). In the next line there will be Y number of integers again separated by commas. You should be able to output all the possible combinations from the Y integers (an integer can be used infinite number of times) which addition will give the value X.
Example Input
10,4
2,5,3,6
The output will be:
2+2+2+2+2
2+2+3+3
2+2+6
2+3+5
5+5
The order of the output does not matter