Advertisement
Guest User

Untitled

a guest
Apr 5th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2.  
  3. class BinaryDigit
  4. {
  5.     static void Main()
  6.     {
  7.         byte BinaryDigit = byte.Parse(Console.ReadLine());
  8.         int n = int.Parse(Console.ReadLine());
  9.         int count = 0;
  10.         for (int i = 0; i < n; i++)
  11.         {
  12.             long chech = long.Parse(Console.ReadLine());
  13.             string binari = Convert.ToString(chech, 2);
  14.             for (int j = 0; j < binari.Length; j++)
  15.             {
  16.                 if (byte.Parse(binari[j].ToString())==BinaryDigit)
  17.                 {
  18.                     count++;
  19.                 }
  20.             }
  21.             Console.WriteLine(count);
  22.             count = 0;
  23.         }
  24.        
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement