0

Write a function that find the sum of positive elements in the array that are located in front of the maximum element

First line contains n (1<=n<=100) Than n numbers are inputed. Output: The sum of elements before maximum. Samples: Input Output 8 10 9 1 -1 -1 9 1 1 0 Help to solve https://code.sololearn.com/c2V10uOcuxnA/#cpp

15th Oct 2020, 4:22 PM
Azat Malgazhdar
Azat Malgazhdar - avatar
2 Respostas
+ 2
First find max element or its index from array by a loop. Then again in another loop find sum of elements from next element of max or from next index of max index sum.. Separate them in your code..
15th Oct 2020, 9:02 PM
Jayakrishna 🇮🇳