+ 1
How to select every elements of an array that don’t have the index 2 for example??
I want to write something that will select all the elements of the array that don’t equal the value of x so I thought it would be like that ( array[!x] ) but it’s not so how? Thanks:)
4 Antworten
+ 5
//let arr be array of size n i.e. last element index -> n-1
//printing all elements excluding element with index x
//say print() method (function) prints on screen
for(int i = 0; i < n ; ++i) {
if( i != x ) {
print(arr[i]) ;
}
}
+ 1
Thanks
0
The index value doesn’t equals x