Need help. Where is a bug? (cpp) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Need help. Where is a bug? (cpp)

Where is a bug in my code? Same function but different bugs. https://code.sololearn.com/cZtIuFv3rIWy For increasing sequence - all good. For decreasing sequence - it dont like when it in end. i have tried to debug in VS but when i fix bug in one sequence - i take it in other place

9th Oct 2018, 1:10 PM
Otakoe
Otakoe - avatar
2 Answers
+ 2
It seems to me that the problems are in the for loops and especially the bottom boundary => when i becomes 0 then arr[i -1] is in fact arr [0 - 1] => arr [-1], so the array is out of bounds. I think you should change i to 1, so the last check will be for arr [0] => the first element in the array.
9th Oct 2018, 3:35 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
thank you so much. and now remain two bugs :) why it not work with long long numbers? and why it not work with short sequence like 174523?
9th Oct 2018, 11:02 PM
Otakoe
Otakoe - avatar