Vladimir76

задача 12

Dec 29th, 2013
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace zad_12
  7. {
  8.     class zad_12
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.Write("entering nomber - n: ");
  13.             int n = int.Parse(Console.ReadLine());
  14.             Console.WriteLine();
  15.  
  16.             Console.Write("enter the nomber on position - p: ");
  17.             int p = int.Parse(Console.ReadLine());
  18.             Console.WriteLine();
  19.             if ((p >= 0) && (p <= 31))
  20.             {
  21.                 int constanta = 1;
  22.                 int newInt = n >> p;
  23.                 bool newBool = newInt == constanta;
  24.                 Console.WriteLine(newBool);
  25.  
  26.             }
  27.             else
  28.             {
  29.                 Console.WriteLine("Enter the value 'p' - 0...31");
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment