Comment detail

2進数の記述 (Nested Flatten)

This comment is reply for 4554 SiroKuro: オーソドックスに。C# だとコンパイル時...(2進数の記述). Go to thread root.

んー。やっぱり C# なら文字列として持ってたほうが良いかな。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using System;
static class Program {
    static void Main() {
        Console.WriteLine(Bin("01001001"));   // 73
        Console.WriteLine(Bin("01101001"));   // 105
    }
    static int Bin(string num) {
        return Convert.ToInt32(num, 2);
    }
}

Index

Feed

Other

Link

Pathtraq

loading...