Bitwise Operations- all exercises with solutions and explanations C#
Създавам такава тема за насърчение и вдъхновение на колегите, които не са успели да разберат напълно побитовите операции. Темата е важна, защото е възможно част от въпросите още на първото интервю за работа да са именно от нея. Примерен въпрос: с кой оператор е възможна размяната на стойности между две променливи , но без да се използва междинна променлива. Отговорът е- с ^ оператора. Моля, ако някой има време и желание нека да покаже как би изглеждал разписан кода на C#.
Установих и че масово на лабовете не остава време за решение на всички задачи, като дори и не успях да открия нито един на C#.
Binary Digits Count https://pastebin.com/6aHn81qb
First Bit https://pastebin.com/hYSG0PGG
P-th Bit https://pastebin.com/y7AV8fr9
Bit Destroyer https://pastebin.com/kZhwJ6du
Odd Times with ^ operator https://pastebin.com/UsHfJQuv
Tri-bit Switch https://pastebin.com/XjpHmEap
https://softuni.bg/trainings/resources/video/38224/video-22-february-2019-martin-paunov-technology-fundamentals-with-csharp-january-2019/2237 - Martin Paunov writes all the exercises in Java.
https://www.youtube.com/watch?v=svD-eXRVCx8 - Nakov lectoring on Bitwise operations.
I create this thread to trying to inspire and motivate fellow, classmates and colleagues, who were not able to fully understand the Bitwise operations. This thread might be important because is possible for some of the questions to pop-up at the job interview. Example: with which operator you can change the value of two variable without use temporary variable. The answer is: with ^ operator. If somebody is willing they could show how the code would look like in C#. I found out that, there is the possibility that a big chunk of the lab's exercises could be left behind because there is not enough time to finished them. I haven't found a single one on C#.
Best regards!