Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class BinarytoDecimal
- {
- static void Main()
- {
- char[] chars = Console.ReadLine().ToCharArray();
- long sum = 0;
- for (int i = (chars.Length-1); i >= 0 ; i-- )
- if (chars[i] == '1')
- sum += (long)Math.Pow(2, ((chars.Length-1)-i));
- Console.WriteLine(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement