添加Lesson2

This commit is contained in:
2025-10-11 11:05:51 +08:00
parent 5e8c571bb3
commit 921e096721
5 changed files with 165 additions and 0 deletions
@@ -0,0 +1,24 @@
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());
}
}
}
}