Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class BinaryDigitsCount
- {
- static void Main()
- {
- byte b = byte.Parse(Console.ReadLine());
- int n = int.Parse(Console.ReadLine());
- uint number = 0;
- byte count = 0;
- for (int i = 1; i <= n; i++)
- {
- number = uint.Parse(Console.ReadLine());
- while (number != 0)
- {
- if (number % 2 == b)
- {
- count++;
- }
- number >>= 1;
- }
- Console.WriteLine(count);
- count = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement