Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ModifyBit
  4. {
  5.     class ModifyBit
  6.     {
  7.         static void Main()
  8.         {
  9.             long n = long.Parse(Console.ReadLine());
  10.             int p = int.Parse(Console.ReadLine());
  11.             byte b = byte.Parse(Console.ReadLine());
  12.             long mask = 1 << p;
  13.             if (b == 0)
  14.             {
  15.                 Console.WriteLine(mask ^ n);
  16.             }
  17.             else
  18.             {
  19.                 Console.WriteLine(mask | n);
  20.  
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement