集合在一起32位二进制中,让1出现在每一位的取值

把1移动到移动0 位1         -00000000000000000000000000000001
把1移动到移动1 位2         -00000000000000000000000000000010
把1移动到移动2 位4         -00000000000000000000000000000100
把1移动到移动3 位8         -00000000000000000000000000001000
把1移动到移动4 位16        -00000000000000000000000000010000
把1移动到移动5 位32        -00000000000000000000000000100000
把1移动到移动6 位64        -00000000000000000000000001000000
把1移动到移动7 位128       -00000000000000000000000010000000
把1移动到移动8 位256       -00000000000000000000000100000000
把1移动到移动9 位512       -00000000000000000000001000000000
把1移动到移动10位1024      -00000000000000000000010000000000
把1移动到移动11位2048      -00000000000000000000100000000000
把1移动到移动12位4096      -00000000000000000001000000000000
把1移动到移动13位8192      -00000000000000000010000000000000
把1移动到移动14位16384     -00000000000000000100000000000000
把1移动到移动15位32768     -00000000000000001000000000000000
把1移动到移动16位65536     -00000000000000010000000000000000
把1移动到移动17位131072    -00000000000000100000000000000000
把1移动到移动18位262144    -00000000000001000000000000000000
把1移动到移动19位524288    -00000000000010000000000000000000
把1移动到移动20位1048576   -00000000000100000000000000000000
把1移动到移动21位2097152   -00000000001000000000000000000000
把1移动到移动22位4194304   -00000000010000000000000000000000
把1移动到移动23位8388608   -00000000100000000000000000000000
把1移动到移动24位16777216  -00000001000000000000000000000000
把1移动到移动25位33554432  -00000010000000000000000000000000
把1移动到移动26位67108864  -00000100000000000000000000000000
把1移动到移动27位134217728 -00001000000000000000000000000000
把1移动到移动28位268435456 -00010000000000000000000000000000
把1移动到移动29位536870912 -00100000000000000000000000000000
把1移动到移动30位1073741824-01000000000000000000000000000000
把1移动到移动31位2147483648-10000000000000000000000000000000

代码

using System;

namespace TestConsole
{
    internal class Program
    {
        static void Main(string[] args)
        {
            uint num = 1;
            for (int i = 0; i < 32; i++)
            {
                string d = Convert.ToString(num, 2).PadLeft(32, '0');
                Console.WriteLine($"把1移动到移动{i.ToString().PadRight(2,' ')}{num.ToString().PadRight(10,' ')}-{d}");
                if (i < 31)
                    num = GetBit(num);
            }
            Console.ReadKey();
        }
        public static uint GetBit(uint number)
        {
            return number * 2;
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值