Advertisement
elena1234

FirstBit

Oct 4th, 2020 (edited)
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace FirstBit
  6. {
  7.     class MainClass
  8.     {
  9.         public static void Main(string[] args)
  10.         {
  11.  
  12.             int number = int.Parse(Console.ReadLine());
  13.             int mask = 1 << 1;//after shift left with 1 we have 1 value in mask at position 1 another are 0
  14.  
  15.             int result = (number & mask)>>1;//after shift right with 1 taken last value(0 or 1) because another are 0 using &
  16.             Console.WriteLine(result);
  17.         }
  18.     }
  19. }
  20.  
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement