Files
Csharp/C#进阶/Lesson2_Stack练习题/Program.cs
T

25 lines
616 B
C#
Raw Normal View History

2025-10-11 11:05:51 +08:00
using System.Collections;
namespace Lesson2_Stack练习题
{
internal class Program
{
static void Main(string[] args)
{
Console.Write("输入一个数字:");
int num = int.Parse(Console.ReadLine());
Stack bio = new Stack();
while (num != 0)
{
int r = num % 2;
bio.Push(r);
num /= 2;
}
Console.Write("你输入的数字二进制为:");
while (bio.Count > 0)
{
Console.Write(bio.Pop());
}
}
}
}