Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
sdsd
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester {sds public class Program { public static void Main(string[] args) { Assert(BinaryHacks.IsOdd(1), "one is odd"); Assert(!BinaryHacks.IsOdd(0), "zero is even"); Assert(!BinaryHacks.IsOdd(2), "two is even"); Assert(BinaryHacks.IsOdd(-1), "-1 is odd"); Assert(!BinaryHacks.IsOdd(-202), "-202 is even"); string expected = "00000000000000000000000000000101"; Console.WriteLine(expected + "(" + expected.Length + ")"); Assert((expected == BinaryHacks.GetBinnaryString(5)), "this is 5"); } public class BinaryHacks { public static bool IsOdd(int number) { return ((number & 1) != 0); } public static string GetBinnaryString(int number) { char[] str = new char[32]; for(int i = 31; i >= 0; i--) { str[i] = ((number & 1) == 0) ? '0' : '1'; number >>= 1; } string fullString = new string(str); Console.WriteLine(fullString + "(" + fullString.Length + ")"); return fullString; } } public static void Assert(bool result, string message) { Console.WriteLine("ASSERT {0} - {1}", result ? "PASS" : "FAIL", message); } } }
run
|
edit
|
history
|
help
0
Range List for C#
Root
Plantera mas com escolhas
asdxscddasdcf
dgh ret ertfh fhf hft85487
Lottofacil
RegEx
reverse a stack
Enumeration
Split and Join