how to link elements of an array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • littlecompiler
    New Member
    • Mar 2012
    • 2

    how to link elements of an array

    I am trying to take the Array v[]={0,1,2,3,4,5,6 ,7,8,9} and put some of the numbers together so I can create a math problem. I have used next_permutatio n to get the possible combinations of the numbers. I am trying to check every combination to see if they work. Like v[1]v[2]v[4]v[0]v[3] to get then number 12403 (that is where I am having the problem) that I can subtract from v[7]v[2]v[0]v[1]= 7201 to get the answer 5202. How can you put v[1]v[2]v[4]v[0]v[3] together to get the number 12403?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    v[1] * 10000
    + v[2] * 1000
    + v[4]* 100
    + v[0] * 10
    + v[3] * 1

    There is an obvious loop here.

    All you need do is caculate your answer by supplying the value for each digit you choose.

    Comment

    Working...