const a = [0.01, -0.02, 0.03, 0.1, -0.04, 0.07, 0.02, -0.05]
let total = 0
let index = 0
//连续子数组最大和
// 0.03 + 0.1 + (-0.04) + 0.07 + 0.02 = 0.18
a.forEach((c)=>{
total = Math.max(total+c,c)
index = Math.max(total,index)
// total+=c
// if(total<c){
// total = c
// }
// if(index<total){
// index=total
// }
// console.log(total,'total-----')
})
console.log(index,total,'index----')