Let\'s say I have an array
k = [1 2 0 0 5 4 0]
I can compute a mask as follows
m = k > 0 = [1 1 0 0 1 1 0]
Using only the mask m and
Assuming what you want is to store only positive integers from an array with minimum steps in C++ this is a sample code:
int j = 0;
int arraysize = (sizeof k)/4;
int store[arraysize];
for(int i = 0; i 0)
{
store[j] = k[i];
j++;
}
}
Or you can directly use elements of k[ ] if you don't want to use for
loop.