#include <iostream>
using namespace std;
unsigned int revert(unsigned int num)
{
unsigned int index=1;
unsigned int t=0;
unsigned int n=0;
int h=31;
int q=1;
for(int i=31; i>=0; i--)
{
index<<=i;
t=index & num;
if(h>=1)
{
t>>=h;
h-=2;
}
else if(q<=31)
{
t<<=q;
q+=2;
}
n=n|t;
index=1;
}
return n;
}
void main()
{
unsigned int num=4294901760;
num=revert(num);
cout<<num;
}
把32位的unsigned int按位反转
最新推荐文章于 2023-02-16 19:33:26 发布