- 1
can someone edit my code becone what i want?
so in my code when i input 4 3 1 2 3 4 // you dont have to see this two first input 1 3 2 4 3 4 the output will be 22 // from (1+2+3)+(2+3+4)+(3+4) but i want the output become like this 6 9 7 //(6 from 1+2+3) (9 from 2+3+4) (7 from 3+4) can someone help me? https://code.sololearn.com/cs38Zrju5GuO/?ref=app
2 ответов
+ 1
+ 1
Add on line 33, total = 0;
Move line 43 to after 45.
You need to zero total for each set you process before summing it and output it's result before going on to the next one.
I'm guessing line 39 is wrong as I expect you want the array value not the index so:
total+=a[k];