P
P
Pavel Lapin2017-09-21 15:59:46
C++ / C#
Pavel Lapin, 2017-09-21 15:59:46

How to write 256 bits into an array of 16 words?

I just started learning programming, such a task:
There is an array int arr[16], you need to write 256 bits one by one using some kind of cycle (s), preserving their natural order (each bit is the result of executing a function in this cycle). On the machine in question, int variables of size 2 bytes

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2017-09-21
@lapinpavel

for (int i = 0; i < 255; i++) {
  arr[i / 16] = (arr[i / 16] & ~(1 << (i % 16))) | (func(i) << (i % 16));
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question