Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C# でスタックを使用して 2 進数を 10 進数に変換するプログラムを作成するにはどうすればよいですか?
ここにヒントがあります。このスニペットは、スタックを使用して 10 進数の整数を 2 進数に変換します。プロセスを逆にするだけです:-P
int num = 50; Stack<int> stack = new Stack<int>(); while (num != 0) { stack.Push(num % 2); num /= 2; } while (stack.Count > 0) { Console.Write(stack.Pop()); }