+ 1

any other way to print pair of numbers whose sum is always less than the third number(n here)??

https://code.sololearn.com/c2it3KkVYj84/?ref=app

5th Oct 2019, 10:28 PM
Harsh Saxena
Harsh Saxena - avatar
6 Respostas
+ 2
Your code is wrong: try the inputs 1 3 2. You must replace if (i+j!=n) with if i+j<n Regarding the code alternatives, there is not much to do. You can try a sort of oneliner like this; https://code.sololearn.com/c2ejROIBwSGm/?ref=app
6th Oct 2019, 5:39 AM
Bilbo Baggins
Bilbo Baggins - avatar
+ 1
?? you can't have a sum of two number that's "always" less than a third number unless you force the user to input something within a range in a while loop. (or am i missing something?)
5th Oct 2019, 10:56 PM
rodwynnejones
rodwynnejones - avatar
+ 1
just check the output of the program by taking inputs 1 1 2
5th Oct 2019, 10:58 PM
Harsh Saxena
Harsh Saxena - avatar
+ 1
aah, i see what you doing now, sorry.. misunderstood.
5th Oct 2019, 11:55 PM
rodwynnejones
rodwynnejones - avatar
0
the sum of 1 and 1 is not less than 2.
5th Oct 2019, 11:00 PM
rodwynnejones
rodwynnejones - avatar
0
since the output is in the form 0 0 0 1 1 0 thus these 3 cases have sum less than 2 only (i.e.0 in first and 1 in rest two)
5th Oct 2019, 11:01 PM
Harsh Saxena
Harsh Saxena - avatar