做一些简单的记录吧,很久没写代码的后果是很多都忘了
#include<iostream>
using namespace std;
int main()
{
int i=5;
int j=8;
cout<<(i>>1)<<" "<<(i<<1)<<endl;
//输出2 10
cout<<(j>>1)<<" "<<(j<<1)<<endl;
//输出4 16
// <<1为左移,>>1相当于右移,对无符号数左移相当于乘以2
//右移相当于除以2
int n=5;
//中间的n相当于n>0的判定
for(;n;n>>=1)
{
}
cout<<n<<endl;
//输出0
cin>>n;
return 0;
}