Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class BinaryToDecimal
- {
- static void Main()
- {
- string binaryInput = Console.ReadLine();
- int result = 0;
- for (int cnt = 0; cnt < binaryInput.Length; cnt++ )
- {
- result = result << 1;
- result += (int.Parse(binaryInput[cnt].ToString()) & 1);
- }
- Console.WriteLine(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment