Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training Big Data and Hadoop Training Java Training  
 

how to print all possible combination that sum to zero??

Ads

 
 

Share on Google+Share on Google+

spencer
how to print all possible combination that sum to zero??
1 Answer(s)      5 years and 4 months ago
Posted in : Java Beginners

? Consider the sequence of digits from 1 through N (N<=9) in increasing order: 1 2 3 4 â?¦ N ?

Insert either a â??+' (for addition) or a â??-â?? (for subtraction) between each of the digits so that the resultant sum is zero. Print all possible combinations that

sum to zero

Example
Enter a num : 7
1+2-3+4-5-6+7=0
1+2-3-4+5+6-7=0
1-2+3+4-5+6-7=0
1-2-3-4-5+6+7=0
Ads
View Answers

April 18, 2012 at 7:31 PM


Consider the sequence of digits from 1 through N(N<=9) in increasing order :1 2 3 4....N Insert either a '+'(for addition) or a '-'(for subtraction) between each of the digits so that the resultant sum is zero. Print all posible combinations that sum to zero. Example: Enter a num : 7 1+2-3+4-5-6+7=0 1+2-3-4+5+6-7=0 1-2+3+4-5+6-7=0 1-2-3-4-5+6+7=0


Ads









Related Tutorials/Questions & Answers:
Advertisements
sum
sum