Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main(string[] args)
- {
- uint num = uint.Parse(Console.ReadLine());
- uint newNum = num;
- string command = Console.ReadLine();
- while (command.ToLower() != "game over!")
- {
- if (command.ToLower() == "even")
- {
- num >>= 1;
- }
- newNum = num & 1;
- num >>= 2;
- int count = 1;
- while (num != 0)
- {
- newNum |= (num & 1) << count;
- num >>= 2;
- count++;
- }
- command = Console.ReadLine();
- num = newNum;
- }
- uint bitCounter = 0;
- while (newNum > 0)
- {
- uint bitCheck = newNum & 1;
- if (bitCheck == 1)
- {
- bitCounter++;
- }
- newNum >>= 1;
- }
- Console.WriteLine("{0} -> {1}", num, bitCounter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment