C++ bitwise operator | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

C++ bitwise operator

How do you find bitwise AND of all elements of the array A = [33554431, 4, 1] in c++

29th Aug 2021, 3:52 PM
Gajendra Sonare
Gajendra Sonare - avatar
1 ответ
+ 3
Unless I misunderstand something, you can just calculate it: int result = ( A[ 0 ] & A[ 1 ] & A[ 2 ] ); For arrays with more elements, one can use a loop instead. However, here the result will be equal to zero anyway, since 4 & 1 = 0.
29th Aug 2021, 4:11 PM
Shadow
Shadow - avatar