List<int> arr = new List<int>();
int num;
do
{
Console.Write("输入一个正整数:");
num = Convert.ToInt32(Console.ReadLine());
if (num <= 0)
{
Console.WriteLine("输入错误!");
}
Console.WriteLine();
} while (num <= 0);
Console.Write("正整数{0}对应的二进制", num);
do
{
arr.Add(num % 2);
num /= 2;
} while (num > 0);
for (int i = arr.Count - 1; i >= 0; i--)
{
Console.Write("{0}",arr[i]);
}
Console.WriteLine();
Console.ReadLine();
}
还有 arr.Add(num % 2);是和List<int>搭配的用吗
万飞