Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int a, b;
- Console.Write("Enter a: ");
- a = Convert.ToInt32(Console.ReadLine());
- Console.Write("Enter b: ");
- b = Convert.ToInt32(Console.ReadLine());
- if (a <= 0 && b <= 0)
- {
- Console.WriteLine("a and b are both below zero, or equal to it, or one of them is below zero and the other is 0");
- }
- else
- {
- if(a>b)
- {
- int tmp = a;
- a = b;
- b = tmp;
- }
- Console.WriteLine("If between a and b there are numbers, in binary form of which there are only four 1, then they will be displayed after this message");
- for (int i=a;i<=b;i++)
- {
- if (i < 0) continue;
- int count = 0;
- int temp = i;
- while (temp > 0)
- {
- int temp1 = temp % 2;
- if (temp1 == 1) count++;
- temp /=2;
- }
- if (count == 4) Console.WriteLine(i);
- }
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment