elena1234

BitDestroyer

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