lundi 15 juin 2015

Remove int value ( inside int array ) at certain index ( or pattern ) C# [duplicate]

This question already has an answer here:

I am storing binary representation of two numbers inside an int array. Example:

num1 =  53 (110101)
num2 = 38 (100110)
array = {1,1,0,1,0,1,1,0,0,1,1,0)

I now want to remove certain bits from the array.Lets say each second (n = 2). Now our array should look like this: array = {1,0,0,1,0,1}.

How can I do that?

If you need more information about how do I decide which bits to remove the formula is as follows: Remove bits at positions: 1, 1+n, 1+2*n, 1+3*n, 1+4*n.. and so on, where 1 >= n <= 100. Since we always add 1, I think '%' should do great for index. But how do I remove those values

Aucun commentaire:

Enregistrer un commentaire