SHARE
TWEET

Untitled

a guest Apr 7th, 2016 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class ModifyBit
  4. {
  5.     static void Main()
  6.     {
  7.        
  8.         ulong N = ulong.Parse(Console.ReadLine());
  9.         byte P = byte.Parse(Console.ReadLine());
  10.         byte v = byte.Parse(Console.ReadLine());
  11.         if (P >= 0 && P < 64)
  12.         {
  13.             if (v == 0)
  14.             {
  15.  
  16.                 ulong mask = (ulong) ~(1 << P);
  17.                 ulong result = N & mask;
  18.                 Console.WriteLine(result);
  19.             }
  20.             else if (v == 1)
  21.             {
  22.                 ulong mask = (ulong)1 << P;
  23.                 ulong result = N | mask;
  24.                 Console.WriteLine(result);
  25.             }
  26.         }
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top