0

help me solve this problem and create a c++ code.

input: 1 2 3 4 sequence in picking number: 3>2>1>4 summation: 8 + 4 + 4 + 4 ( this is per each picked number on the sequence) case A: multiplying the adjacents of the number picked ex: 1st # is 3 picked,from [1 2 3 4] its adjacents is 2 & 4, its product is 8, then 3 is removed and array is compressed [1 2 4]. 2nd # picked is also similar to case A case B: 3rd # is 1 picked, from [1 4] looking at its adjacent only the right side is present which is 4 so no need for the product and its equal to 4, 1 is removed from the array [1 4] and compressed which left as with [4] case C: the last # picked 4 has no left and right adjacents so its equivalent to the number itself. Based on the cases given the summation of sequence is equal to 20. NOTE: Array is limited to 10 numbers only. its values can vary from 1 to 1000.

25th Jul 2019, 12:51 PM
Lester Vincent S. Ponce
Lester Vincent S. Ponce - avatar
1 Resposta
+ 1
Try GitHub
27th Jul 2019, 7:15 AM
Da2
Da2 - avatar