Quote:
Originally Posted by mr.montreal
hi all, the question is:
write a program that inputs 6 integers,and then checks to see if any combination of exactly three of the first 5 integers adds up to the last integer.
test cases:
1)input -----> 1 -2 4 -1 15 17 output -------> Yes. -2+4+15=17
2) 3 12 11 -4 16 7 No.
|
Any combination? If you really mean that then it sounds like everybody has misinterpreted your question.
For instance, 3 5 7 8 -2 6 -> yes, 3+5-2=6.
If this is, indeed, the problem you're trying to solve then your printed algorithm is totally naive and no one has come close to solving it.
I'll wait to see if this is your actual problem but this isn't hard to solve. My intuition is that you'll need to solve it recursively. Are you familiar with recursion?