Answer the question
In order to leave comments, you need to log in
How to remove an array element in Processing?
How to remove an array element in Processing?
It is from the array "int[] integers = {1, 2, 3};" and not from "IntList integers = new IntList ();"
Answer the question
In order to leave comments, you need to log in
int[] removeNthElm(int[] array, int nElement)
{
// перемещаем нужный элемент в конец
for(int i = nElement - 1; i < array.length - 1; ++i)
{
// типа swap
int a = array[i];
array[i] = array[i + 1];
array[i + 1] = a;
}
return shorten(array);
}
void draw()
{
int[] a = {1, 2, 3, 4, 5};
a = removeNthElm(a, 1);
printArray(a);
exit();
}
OUT:
[0] 2
[1] 3
[2] 4
[3] 5
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question