0
Hi guys i need to delete item from arra and print new array, what wrong?
9 Antworten
+ 3
what is the expected input?
index of item to be deleted or value of item to be deleted?
in second case, would you delete only the first encountered value matching or all values matching?
0
Thanks a lot guys, visph i want to delete by index
0
so, if x is the index, you may test if it is valid (0 <= x < length), and iterate i from x+1 to length (not included), and only set arr[i-1] = arr[i]...
do not forgot to update length ( = length-1), to not use more than valid index ;)
0
[edit] Olka Berkovich some corrections done ^^
https://code.sololearn.com/cSds0PEdHp7F/?ref=app
0
visph thanks a lot but a code all time print only else
0
We dont entry to if, and here not print anything, its not work correctly...
- 1
Olka Berkovich what do you mean by "a code all time print only else"?
- 1
it works correctly for me, if you provide valid input (index between 0 to 5 inclusive)... it only execute else for invalid index ^^