Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace zad_13
- {
- class zad13
- {
- static void Main(string[] args)
- {
- Console.Write("Enter the nomber - n : ");
- long n = long.Parse(Console.ReadLine());
- if ((n >= Int32.MinValue) && (n <= Int32.MaxValue))
- {
- Console.Write("Enter the position - p : ");
- int p = int.Parse(Console.ReadLine());
- if ((p >= 0) && (p <= 31))
- {
- long n1 = n & (1 << p);
- if (n1 == 0)
- {
- n = n | (1 << p);
- Console.WriteLine("New nomber -n = " + n);
- }
- else
- {
- n = n ^ (1 << p);
- Console.WriteLine("New nomber -n = " + n);
- }
- }
- else
- {
- Console.WriteLine("Enter a value in the range:" + "0" + "...." + "31");
- }
- }
- else
- {
- Console.WriteLine("Enter a value in the range : " + Int32.MinValue + "...." + Int32.MaxValue);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement