Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Декларирайте променлива от тип byte и я инициализирайте с произволна стойност.
- * Отпечатайте на екрана "access granted", ако 4-тия бит (позициите започват от 0) е 1
- * или "access denied" ако 4-тия бит е 0 */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ex6
- {
- class Program
- {
- static void Main(string[] args)
- {
- byte n = 56; //00111000
- int bit4 = 1 << 4; //00010000
- Console.WriteLine((n & bit4) == bit4 ? "access granted" : "access denied");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment