+ 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:)

20th Jan 2018, 6:35 PM
Justin Renaud
Justin Renaud - avatar
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]) ; } }
20th Jan 2018, 7:58 PM
code learner
code learner - avatar
+ 1
Thanks
20th Jan 2018, 9:00 PM
Justin Renaud
Justin Renaud - avatar
0
The index value doesn’t equals x
20th Jan 2018, 7:39 PM
Justin Renaud
Justin Renaud - avatar