添加Lesson2
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user