1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Java prob.

  1. Aug 9, 2012 #1
    I have an array of 3 known elements.I know that 2 elements of them have the sum of 100 and I need to find the location of the two elements which have this sum
    5 25 75
    the solution for this prob.
    is second & third location

  2. jcsd
  3. Aug 9, 2012 #2


    User Avatar
    Homework Helper

    In this case, there are only 3 possiblities, A[0] + A[1] or A[0] + A[2] or A[1] + A[2].

    For a more generic solution, you could use a double loop to handle an array with N elements. I don't know if this will be a later assignment for your homework.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook