• Post Reply Bookmark Topic Watch Topic
  • New Topic

simple Programee on collection  RSS feed

 
srinivasa Avvaru
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose i have sorted list which has integers then write a program that any of 2 integer sum is equal to x(which we give input)?
Ex: i have 1,2,3,4,5 in list i have gave x as 9 then i need to write a program that the number 9 i s equal to any of the integers.Her in that case(4+5=9) so i need this program for this logic?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so i need this program for this logic?

Hi. The ranch is NotACodeMill. You'll have to DoYourOwnHomeWork. First, show us what you have managed to write.
 
srinivasa Avvaru
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks....Christophe Verré i will do my self........
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need a nested loop. Basically, for each number you combine it with each other number. You can make it a bit faster by using the fact that + is associative*. You'll only need to combine each number with numbers located nearer the end; after all.


* if x + y == z then y + x == z
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!